PDA

View Full Version : variables not shown in templates


FloatBird
05-20-2011, 09:26 AM
hello,

I don't understand this. I made a plugin for general use like this:

hook name: global_start (i checked also other hooks but nothing working)
plugin code:
$myvar = "vb4 plugin not showing variables";

and in 'navbar' template I added this:

{vb:var myvar}

but unfortunately, myvar not shown in 'navbar' ..
it's work if I do a new hook and add to the template, or create new template for just this single variable? help please.

nitra1000
05-20-2011, 12:09 PM
You need to register it to work... a search of the forums will get you your answer

FloatBird
05-20-2011, 12:39 PM
thank you, but I am asking because I already read article about how to register variables. my problem is that I don't want to create new template .. I just want to add my var to an exist template .. I tried this but get an error:

$templater = vB_Template::create('navbar');
$templater->register('my_var', $my_var);
$templater->render();

Carandiru
05-20-2011, 12:49 PM
<a href="http://www.vbulletin.com/forum/entry.php/2387-Pushing-your-variables-to-vBulletin-4-templates" target="_blank">http://www.vbulletin.com/forum/entry...in-4-templates</a>
or is this the article you've already read?

Disasterpiece
05-20-2011, 12:59 PM
vB_Template::preRegister('navbar',array('myplugin_ output' => $myplugin_output));

^this

FloatBird
05-20-2011, 10:14 PM
thx guys.. it's work perfect