Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2011, 04:19 PM
SiteTalkZone SiteTalkZone is offline
 
Join Date: Dec 2008
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to hook in all page of vBulletin 3.84

Hi all,
I am researching to write my plug-in in vB3.x

I would like to insert addition information into header of my forum (header template).
I wrote a plug-in and used code following to insert:
Code:
global $vbulletin;
$additionalVar = "Additional Content";

$vbulletin->templatecache['header'] = str_replace('<!-- Additional-Content -->', '<!-- Additional-Content --><br />'.$additionalVar, $vbulletin->templatecache['header']);
I tried hook this plug-in to forumhome_start location.
And in the header template, I putted the text <!-- Additional-Content --> into location that I want to.

However, when I accessed to my forum, it changed nothing. But if I tried to use command print $additionalVar to print directly in plug-in, so "Additional Content" string displayed on top of the forum homepage, but when I accessed another page, the text disappeared.

So I would like to know:
- How to transfer content of variable from plug-in to template.
- Which location need to be hooked in order to change for all page of forum.

Thanks!
Reply With Quote
  #2  
Old 01-20-2011, 04:30 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think choosing a different hook will solve both those problems. If you look in global.php and search for "parse headinclude", you can see where the header template is used, so obviously you want to pick a hook location before that (you can also see which hooks are before that by looking for "fetch_hook" in the code).

I think you could prbably use global_start.
Reply With Quote
  #3  
Old 01-21-2011, 02:52 AM
SiteTalkZone SiteTalkZone is offline
 
Join Date: Dec 2008
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks kh99,
I did following your instruction and found location need to hook for header template. That is parse_templates

However, I have not yet found solution for the first issue.

----------------------------------------------------------------------------------------
I tried to hook into parse_template location, it has an error when I used following command:
Code:
$vbulletin->templatecache['header']  = "New Content's Header";
The error is:
Code:
Parse error: syntax error, unexpected T_LNUMBER in C:\pathtoforum\global.php(833) : eval()'d code on line 3
Reply With Quote
  #4  
Old 01-21-2011, 12:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I created a test plugin using parse_templates and this code:

Code:
$vbulletin->templatecache['header']  = "New Content's Header";

and it works without an error.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07659 seconds
  • Memory Usage 2,188KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete