PDA

View Full Version : I made a variable in a plugin. How do I use it in a template now?


Jeremy8
06-18-2010, 05:04 AM
This is my plugin:
$timestamp = TIMENOW - $vbulletin->options['hourdiff'];
$hourofday = date("G", $timestamp );

$templater = vB_Template::create('headinclude');
$templater->register('hourofday', $hourofday);
$templater->render();

So now I get my variable in my template like this right? {vb:raw hourofday}

But it doesn't let me do this? <vb:if condition="{vb:raw hourofday} == 1">

I want to do that...

DragonBlade
06-18-2010, 06:56 AM
It should be this:

<vb:if condition="$hourofday == 1">

Jeremy8
06-18-2010, 12:37 PM
I have the above plugin using a hook location of Parse Templates.

And this is my added code at the bottom of headinclude:

<vb:if condition="$hourofday == 9">
<style type="text/css">
html
{
background-color: #000066;
}
</style>
</vb:if>

It doesn't work. The variable has no value in it or something.

--------------- Added 1276869271 at 1276869271 ---------------

Nevermind I got it to work.

I changed:

$templater = vB_Template::create('headinclude');
$templater->register('hourofday', $hourofday);
$templater->render();

to


vB_Template::preRegister('headinclude',array('hour ofday' => $hourofday));

thanks