The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Using variables in templates
I am having issues with this. I just upgraded from 3 to 4 and want to have a variable that I can use in an If Statement in a template.
So in a template I can do this: <vb:if condition="$var == 1"> In a pluggin I can do this: Code:
$var=1; vB_Template::preRegister('header',array('var' => $var)); Code:
{vb:raw var} If I try to use $var I just get the text $var and not the value. Please advise. Thanks |
#2
|
||||
|
||||
You're likely putting your code in the wrong plugin, which pluigin do you have it in, did you try moving it to another plugin point?
|
#3
|
|||
|
|||
What template are you trying to insert into?
|
#4
|
|||
|
|||
I added it to global start, I tried a few others but was just guessing at that point.
I want it in the header. If I do VB:Raw I can get the value no problem. But if I do $Var, I get just the text. The issue being I want to be able to use an If Statement. Basically this is for ads and I have a variable saying what type it is, 1 for flash, 2 for image. Before I had an If conditional and based on that variable I could play the flash or add a hyperlink for the image. But can't seem to get the syntax right for using the variable in the If statement. Thanks |
#5
|
|||
|
|||
Quote:
Show me your "if condition" statement. |
#6
|
|||
|
|||
Not sure what I was doing wrong before, but now it seems to be working fine.
I ended up deactivating all the custom plugins because I was getting errors elsewhere. And now when I try adding these variables the same way I was before it works so not sure what was the cause of the issue. Could have been a typo as well but I tried it several times with simple variables like $x and it wouldn't work so not really sure. Thanks for the assistance. |
#7
|
|||
|
|||
Quote:
I currently have a board that is doing the same behavior, but only on "headinclude". The template is rendered correctly in database, the right plugin code is in the datastore, the right template page (styleid) is displaying -- yet the variable is not being replaced in the template. I am a bit baffled, but I aim to track down the problem tonight. I normally just put the code directly in the template, but after reading your post and @chris's; I decided to check it out. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|