PDA

View Full Version : How to hook in all page of vBulletin 3.84


SiteTalkZone
01-20-2011, 04:19 PM
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:

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!

kh99
01-20-2011, 04:30 PM
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.

SiteTalkZone
01-21-2011, 02:52 AM
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:
$vbulletin->templatecache['header'] = "New Content's Header";

The error is:
Parse error: syntax error, unexpected T_LNUMBER in C:\pathtoforum\global.php(833) : eval()'d code on line 3

kh99
01-21-2011, 12:54 PM
I created a test plugin using parse_templates and this code:

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


and it works without an error.