PDA

View Full Version : ad_showthread_firstpost_start troubles with plugin


RedFoxy
12-10-2009, 11:36 AM
Hi!
I created a plugin (admincp ->Plugins & Products -> Add New Plugin) with:

Product: Vbulletin
Hook Location: global_start

Plugin PHP Code:
ob_start();
$variable_name = "xyzabc";
ob_end_clean();
If I use $variable_name in ad_header_logo and other templates it goes but if I put it in ad_showthread_firstpost_start it doesn't go.

I tried adding the variable in global too:
ob_start();
global $variable_name;
$variable_name = "xyzabc";
ob_end_clean();But nothing

How can I fix it?

kh99
12-10-2009, 12:53 PM
The problem is that the ad_showthread_firstpost_start template is processed in the function construct_postbit (in includes/class_postbit.php), so it can't see that variable you created. Putting "global $variable_name" in your plugin doesn't help because it needs to be in the function where the variable is used.

There is a hook "postbit_display_complete" right before the ad_showthread_firstpost_start is processed, so if you could make a plugin to set your variable there that should work. If not, maybe you could create a plugin that simply has "global $variable_name;" and put it on the postbit_display_complete hook.

RedFoxy
12-10-2009, 03:25 PM
that's sad...

BTW I tried global just thingking that it was in a function

kh99
12-10-2009, 03:30 PM
Well, I wasn't clear - putting "global $variable_name;" before the assignment *might* have worked in a different situation, it just turns out in this case it's the template eval that's in a function.

--------------- Added 1260467433 at 1260467433 ---------------

Oh yeah, another thing I meant to mention - if that's the only code in your plugin, I don't think you need the ob_start() and ob_end_clean(), you only really need that when your php code produces output you want to capture.

RedFoxy
12-10-2009, 04:18 PM
no it isin't, there are other parts, it was only an example