PDA

View Full Version : Default text to display in every first post


donkspurs
07-26-2014, 04:14 PM
I'm trying to display some text which will show in every first post in every thread, but I also only want it to display in a specific forum section. The id of the forum is definitely 22 and I've already found some code which apparently should work.

Here is the code I am currently using in the template "ad_showthread_firstpost_start".

<vb:if condition="$forum[forumid] == 22">

This is the custom text.

</vb:if>

However for some reason this text doesn't display at all in the threads in the specified forum.

If I remove the if condition then the text displays fine, but it obviously then displays in every single thread on the site.

I am testing this on a dev forum so the forums are turned off. I can't see that being an issue but thought worth mentioning in case.

Any help would be much appreciated! Thanks.

Paul M
07-26-2014, 05:18 PM
Have you tried using $thread rather than $forum ?

donkspurs
07-26-2014, 05:23 PM
Have you tried using $thread rather than $forum ?

Thanks for the help.

I hadn't tried that until you just suggested it but sadly it didn't make any difference. :(

donkspurs
07-27-2014, 05:31 PM
Has anyone on here ever tried to get default text into the first post of every threads in a specific forum?

Must be someone on here! Any help on how to do it would be greatly appreciated, thanks!

Paul M
07-28-2014, 11:12 AM
Looking at the code, you cannot do this without a using a hook.

No variables other than the adsense details are registered for that template when its created, so you need to pre-register either $forum or $thread.

vB_Template::preRegister('ad_showthread_firstpost_ start',array('thread' => $thread));


The 'postbit_display_complete' hook should be ok to use.

donkspurs
07-28-2014, 04:43 PM
Looking at the code, you cannot do this without a using a hook.

No variables other than the adsense details are registered for that template when its created, so you need to pre-register either $forum or $thread.

vB_Template::preRegister('ad_showthread_firstpost_ start',array('thread' => $thread));


The 'postbit_display_complete' hook should be ok to use.

Thanks once more for the help!

Unfortunately I haven't done any work with hooks before so not sure where to start!

Where would I find the 'postbit_display_complete' hook? Thanks again.

Lynne
07-28-2014, 05:00 PM
Go to admincp > Plugins and Products > Add New Plugin and the hooks location is a dropdown and you will find it there.

donkspurs
07-29-2014, 12:07 AM
Thank you guys! That worked brilliantly.

Excellent help. Really appreciate it! :)

DannyITR
08-26-2014, 03:54 PM
Is there any way to adapt this so that the text is entered into the post box while the user is typing the post?

I want to have default text in my for sale sections so users will know what is expected in terms of info.

Lynne
08-26-2014, 08:01 PM
Go search for the Stencil Mod. That should do what you want.

CAG CheechDogg
08-26-2014, 08:04 PM
Is there any way to adapt this so that the text is entered into the post box while the user is typing the post?

I want to have default text in my for sale sections so users will know what is expected in terms of info.

You can do this ...

New Plugin

Hook Location: newthread_form_start

Tittle: Auto Fill Data For New Threads

Execution Order: 5

Plugin PHP Code:

if ($foruminfo['forumid'] == forumID)
{
$newpost['message'] = "
(Add your text here)

Add more text here

";
}

Make sure you change the forum ID to the forum you want this in ...

Credit goes to kh99 for this .....