View Full Version : Running Quick PHP in a Template Via Plugin
evenmonkeys
07-07-2012, 02:30 AM
I'm trying to just make a very simple and quick variable that I'd like to place into a template. I made a plugin using global_start and just put something along the lines of:$variable = 1;Then I try to pull that variable in a template, but it doesn't work.
Am I missing something?
Simon Lloyd
07-07-2012, 03:06 AM
You're correct you simply put $variable wherever you want to see the number 1 :)
evenmonkeys
07-07-2012, 03:41 AM
It doesn't work, unfortunately.
My plugin literally is under global_start:$variable = 1;Within my template is Variable = $variable.
Doesn't work.
Simon Lloyd
07-07-2012, 04:35 AM
Nope, in your template just put $variable
or you can use it like this <td>$variable2345</td> which will give you 12345
evenmonkeys
07-07-2012, 01:18 PM
Right. But it doesn't work. I put $variable and it shows nothing. I pull up the source and it's like it's not even there.
Where are you using your template? Some templates are used inside a function, and then you can't use global variables directly. You could try using $GLOBALS['variable'].
evenmonkeys
07-07-2012, 01:36 PM
I guess that makes sense.
I'm modifying 4 templates:
forumhome_forumbit_level1_nopost
forumhome_forumbit_level1_post
forumhome_forumbit_level2_nopost
forumhome_forumbit_level2_post
Simon Lloyd
07-07-2012, 01:41 PM
I guess it would be best if you showed us EXACTLY what you are using, with what hook and where you are trying to use it in those templates.
I guess that makes sense.
I'm modifying 4 templates:
forumhome_forumbit_level1_nopost
forumhome_forumbit_level1_post
forumhome_forumbit_level2_nopost
forumhome_forumbit_level2_post
I think that's your problem - those are used in the function construct_forum_bit() (in includes/functions_forumlist.php), so your global variable isn't in scope.
evenmonkeys
07-08-2012, 07:42 PM
Awesome. Thank you. I see what I'm not doing correctly. I just had to change the hook location. Appreciate the help, kh99.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.