The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Problem with using plugin variables in templates
So for some time now I have been ripping my hair out trying to figure out how to use my plugin variables in my custom templates. After reading countless threads and articles on preReigsting my variables, I have zero luck in actually accomplishing this task.
Here's my basic ripped plugin example hooking newthread_forum_start Code:
$my_var = "abc"; $templater = vB_Template::create('newtemplate'); $templater->register('my_var', $my_var); $myrendervar = $templater->render(); vB_Template::preRegister('newthread',array('myrendervar ' => $myrendervar)); What's the deal? What am I not understanding about plugin variables that's preventing me from using basic ones? |
#2
|
||||
|
||||
You didn't register $my_var to be used in newthread, you only registered it to be used in newtemplate.
|
#3
|
||||
|
||||
Quote:
You should have a template created named "newtemplate" with {vb:raw my_var} in it. Are you doing this? |
#4
|
|||
|
|||
I got it working thanks to Lynne. I did not know that 'newtemplate' was suppose to target the template I was editing, instead I thought it was some kind of a unique identifier.
But a new problem arises, trying to use my new variable's from the plugin, in a template conditional. (example) PHP Code:
(I've used customid as well to cover all my bases) Code:
<vb:if condition="$foruminfo[forumid] != $checkid"> ... </vb:if> |
#5
|
||||
|
||||
Have you tried outputting checkid to see what it outputs? This should be your first port of all. Alway output the items you are going to compare to screen to see whether they contain what you expect before you try to compare them.
I believe $foruminfo[forumid] should actually be $forum['forumid'] |
#6
|
|||
|
|||
Quote:
I tried printing the variable checkid and instead of getting the number 4, I got "Post new thread" and some submit buttons(as if I re-click new topic). Tab confused on this one, as clearly there's some kind of error within the mapping of the variable. But if I echo $customid I do indeed get 4. Some where in PHP Code:
|
#7
|
||||
|
||||
because your actually preregistering the template into itself. You register the variable with newtrhead then you are registering newthread, with newthread
|
#8
|
|||
|
|||
oh wow, your absolutely right. I had the idea that you had to go through thous ridiculous loops to per-register your variables.
Got it all working. Thanks. |
#9
|
||||
|
||||
No prob. Glad its sorted for ya
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|