The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Problem with use of plugins and variables
Hello,
i wanted to include a file inside a custom template (but the problem is for any variable defined in a plugins that i want to use in a custom template) vB version 4.1.9. i created a new plugins called google_analytics with hooklocation global_start that's the code of the plugins: Code:
ob_start(); include("../google_forum.inc.php"); $google_analytics = ob_get_contents(); ob_end_clean(); echo "pippo"; echo date("Y"); then i put in my global.php the following line Code:
vB_Template::preRegister('footer',array('google_analytics ' => $google_analytics)); Code:
{vb:raw google_analytics} now the questions are: should i use the preRegister method to have the variables correctly addressed in my templates???? where to put this code (i mean the vBTemplate........et...etc...) cause anytime i ugrade the version i overwrite almost all files such as global.php for example?? why if i comment out the line in the global.php for variable registration and i delete the declaration of the variable in my template i get always at the beginning of my html source code (and never in the place where i put the variable in the template) "pippo2011"???? Thank you and Regards Franco |
#2
|
||||
|
||||
First off, global_start is a deprecated hook location:
Quote:
|
#3
|
|||
|
|||
Quote:
Anyway to preregister variables may i create a plugin with an appropriate hook???? |
#4
|
||||
|
||||
It is much easier to write a plugin to preregister the variables than to edit the code. But that is your choice.
You may be better off figuring out why is isn't working using the global_bootstrap_init_start rather than continuing to use global_start. global_start will disappear soon. It's been almost two years since it's been deprecated now. |
#5
|
|||
|
|||
You should be able to put your vB_Template:reRegister line at the end of the same plugin as the other code, and if you do that I'm guessing it will work using global_bootstrap_init_start.
|
#6
|
|||
|
|||
ty Lynne and Kh99 for the answers.
Now i got it to work..... i put all preregisters in a plugin but the funny things was that some were working and some not and just changing execution order they got to work, all but one that there is no way to make it work except putting the preregister in the global.php file with the hook global_start i tried really everything Ty a lot |
#7
|
|||
|
|||
Are you using more than one plugin? You should be able to put everything in one plugin, especially if they're using the same hook. If you have to use different hooks for some reason then you may have to declare some variable global.
|
#8
|
|||
|
|||
yes i m using more plugin and the variables are all in the footer and in the same hook ; i tried to put preregistration in the same plugin like the variable declaration and assignment, as you suggested, but it did not work
ty well i realized it's a problem of variable scope; i'm assigning to a variable the value of $forumid.... if i set in the plugin global_start as hook the variable exists and it assumes the right value... if i use global_bootstrap_init_start ashook the variable is not set or visible and is NULL. i used global_bootstrap_complete as hook, defined the var forumid global, and put the preregister in the same plugin and nowit works but that' s really an ugly workaround. if i use global_start all works perfectly without needs of global or preregister in the same plugin; with global_bootstrap_intit_start no way to make it work whatever i tried. there isan equivalent hook for global_start cause the one suggested is not workingat all........... Ty |
#9
|
||||
|
||||
Try $GLOBALS[forumid] instead of $forumid
|
#10
|
|||
|
|||
If i use global_bootstrap_complete as hook it works with $GLOBALS[forumid] but if i change hook as global_bootstrap_init_start does not work anymore.
i think itwould be nice for variable scope keep global_start as hook............ ty a lot Lynne may i ask u something more on this thread??? for example i need an equivalent for the conditional <if is_array($navbits)>.... if i use the vB4 version <vb:if is_array ($navbits) > it gives me always FALSE. I need that for thebreadcrumb |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|