vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   ad_showthread_firstpost_start troubles with plugin (https://vborg.vbsupport.ru/showthread.php?t=229903)

RedFoxy 12-10-2009 11:36 AM

ad_showthread_firstpost_start troubles with plugin
 
Hi!
I created a plugin (admincp ->Plugins & Products -> Add New Plugin) with:

Product: Vbulletin
Hook Location: global_start

Plugin PHP Code:
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:
PHP Code:

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 [DATE]1260467433[/DATE] at [TIME]1260467433[/TIME] ---------------

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


All times are GMT. The time now is 03:53 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06588 seconds
  • Memory Usage 1,714KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete