vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Default text to display in every first post (https://vborg.vbsupport.ru/showthread.php?t=313246)

donkspurs 07-26-2014 04:14 PM

Default text to display in every first post
 
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".

Code:

<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

Quote:

Originally Posted by Paul M (Post 2508372)
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.

PHP Code:

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

Quote:

Originally Posted by Paul M (Post 2508656)
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.

PHP Code:

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.


All times are GMT. The time now is 05:21 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01134 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete