Log in

View Full Version : Plugin Variables, and Templates Help


C Braithwaite
10-18-2006, 08:44 AM
Hiya, i was trying to make a plugin which would display in any template on my site. i simplified the plugin to:

vBulletin
global_start

$mytestvariable = "Hello World";

and then placed the $mytestvariable variable into my template, but it would not show.

Anyone know how i can create a variable that i can use on any page?

Thanks in advance

Adrian.
10-18-2006, 11:18 AM
I put the PHP in the hook location, to where i want my variable.

If that makes sense, for example, if i wanted to display the variable on the forum home, i would choose the location "forumhome_start".

That should work.

C Braithwaite
10-18-2006, 11:46 AM
I put the PHP in the hook location, to where i want my variable.

If that makes sense, for example, if i wanted to display the variable on the forum home, i would choose the location "forumhome_start".

That should work.


Yep that makes sense, however what i need is the variable to be available on all pages, including my custom pages (well, page) - is that possable?

if not, i could code the plugin into my custom page - where would i put the hook for displaying threads?

ps, cheers for the reply :)

Kirk Y
10-18-2006, 04:13 PM
Try hook location 'global_start'.

C Braithwaite
10-18-2006, 09:48 PM
Try hook location 'global_start'.
yeh i tried that after reading another one of your posts, but it wouldnt work for me. :S

Kirk Y
10-18-2006, 10:02 PM
What template are you trying to access the variable in? Because it should work.

C Braithwaite
10-19-2006, 07:56 AM
What template are you trying to access the variable in? Because it should work.


POSTBIT, and a custom one.

for postbit, it works in postbit_display_complete, but not global_start

Kirk Y
10-19-2006, 11:00 AM
What version of vBulletin are you using?

C Braithwaite
10-19-2006, 11:57 AM
What version of vBulletin are you using?

Powered by vBulletin Version 3.6.2

Kirk Y
10-19-2006, 04:00 PM
Weird. I always assumed that global_start was... well, global.

I guess you'll just have to use postbit_display_start. For your Custom Page, it'd probably be simpler to just include the PHP code within the file itself, rather than using hooks.

C Braithwaite
10-19-2006, 05:45 PM
Weird. I always assumed that global_start was... well, global.

I guess you'll just have to use postbit_display_start. For your Custom Page, it'd probably be simpler to just include the PHP code within the file itself, rather than using hooks.


i thought it was global also, and supprisingly in the global_start works for my custom page but not the postbit template! lol

Paul M
10-19-2006, 06:30 PM
global_start is called on all vb pages.

I believe the postbits are built from within functions so you are likely to need to call global $yourvariable in a postbit hook to get it to work.

An easier way would be to create your own array $vbulletin->myvars and then use $vbulletin->myvars['var1'] etc, as $vbulletin is already globalised in most places.

C Braithwaite
10-22-2006, 09:05 AM
global_start is called on all vb pages.

I believe the postbits are built from within functions so you are likely to need to call global $yourvariable in a postbit hook to get it to work.

An easier way would be to create your own array $vbulletin->myvars and then use $vbulletin->myvars['var1'] etc, as $vbulletin is already globalised in most places.


that's a good idea, ill give that a shot. :D

Xyzzy
03-11-2007, 11:12 PM
Weird. I always assumed that global_start was... well, global.

I guess you'll just have to use postbit_display_start.
I wish I had seen this, oh, about 18 freaking hours ago.

:)

:up:

Marco van Herwaarden
03-12-2007, 08:11 AM
global_start is called once on each page. The postbit_* hooks are called for each post.