View Full Version : Variables in Hooks
LMimo
06-10-2010, 10:32 PM
I have a variable problem in a hook. Can anyone help with why case 2 or case 3 do not work? Thanks in advance for any replies.
Case 1 (Works fine)
$test1 = "333";
build_something($test1, 0, 0)
Case 2 (Does not work)
$another1 is 333 when displayed in a template
$test1 = $another1;
build_something($test1, 0, 0)
Case 3 (Does not work)
$another1 is 333 when displayed in a template
build_something($another1, 0, 0)
Lynne
06-10-2010, 11:45 PM
Very difficult to say when you aren't telling us which hook location and which template. It could be the variable for the template is rendered after your plugin and so the variable isn't available at the time.
LMimo
06-11-2010, 12:02 AM
Very difficult to say when you aren't telling us which hook location and which template. It could be the variable for the template is rendered after your plugin and so the variable isn't available at the time.
In case 2, if I actually put $test1 in the template it will actually display 333. So the 333 does actually get to the $test1 variable. For some reason though it will not work with it the same as in case 1.
It's as if this works:
$test1 = "333";
build_something($test1, 0, 0)
But this doesnt:
$another1 = "333";
$test1 = $another1;
build_something($test1, 0, 0)
Lynne
06-11-2010, 12:47 AM
Sorry, but what is above should work. If you want us to figure out why it isn't working, you'll need to be more specific and post code, hook locations, and template stuff.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.