The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Plugin variables in template conditionals
Hi
Any chance that someone could tell me how to declare a variable in a plugin, such that that variable can then be used in a template conditional? Thanks |
#2
|
||||
|
||||
Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide
|
#3
|
|||
|
|||
I really appreciate the link Lynne, but it doesn't actually answer the question I asked, which was:
Quote:
Any other advise would be gratefully recieved. |
#4
|
||||
|
||||
Yeah, you need to preregister the variable for use in the template and then you are allowed to use it in the template conditional. It's the same variable that can be either spit out directly or used in a condition.
|
#5
|
|||
|
|||
Thank you so much! Did the trick.
Sorry if my previous answer was a little rude, my only excuse is that I'm going nuts because of the complete lack of decent developer documentation available for vbulletin. If I could find the answers out myself, then I wouldn't be bothering the board! |
#6
|
||||
|
||||
I have a variable in the "style_fetch" hook called $mobile (for the mobile device detection mod, unimportant for this question, but that's why it's in "style_fetch").
I cannot, for the life of me, preRegister this variable for the "footer" template!!! Why does this not work!? in "style_fetch": Code:
$TEST = "TESTING"; vB_Template::preRegister('footer', array('TEST' => $TEST)); in "footer" template: Code:
{vb:raw TEST} Nor does the variable work in a conditional. What am I doing wrong!? Why does this have to be so complicated and confusing? I haven't seen even one post where someone preRegisters a variable and then uses it in a conditional, either... would the variable above be $TEST? I'm so frustrated. |
#7
|
||||
|
||||
Did you try template_register_var ?
|
#8
|
|||
|
|||
Your code, exactly as you have it posted works for me.
|
Благодарность от: | ||
BlueChipEarth |
#9
|
||||
|
||||
nhawk, I can't figure out why mine won't work... let me review the code and make sure I'm not in some parent if statement or something...
In the meantime, can you tell me what the registered variable would look like, or how to use it, in a conditional? Would it just be "$TEST" like: Code:
<vb:if condition="$TEST == 'TESTING'"> something </vb:if> Hmm... seems I had a logic error in my code. I'm working within a mod, as I said earlier, and I think that since I clicked "desktop version" it was completely skipping mobile detection and, therefore, not setting the variable I was trying to access. D'oh!!! I'm too tired today for programming... lousy downstairs neighbor found 12:30 AM a perfectly acceptable time to practice his guitar. He needs practice, to be sure... but let's do it at normal human hours, eh, Rock'n'Roll Dracula!? |
#10
|
|||
|
|||
The conditional the way you have it is correct.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|