<style type="text/css"> <!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } --> </style> Prior to vBulletin 4, you were able to refer to your plugin's variables exactly as you would refer to them within a standard PHP script. Due to the changes to the way vBulletin's templates work, this is no longer the case.
Once you understand the new vBullein 4 template variable format, referring to your plugin's variables will be simple. Let's take a look at the new variable format by comparing some examples of how they look in vBulletin 3.8.X and vBulletin 4.
Example 1
In this example, we will assume that you have written a plugin that stores its data within the variable $myplugin_output. Using vBulletin 3.8.X, you could simply insert that variable within your templates and have the output display on the site.
Within vBulletin 4, this same variable from your plugin would now be referenced as follows.
{vb:raw myplugin_output}
Within vBulletin 4, all of the new template variables appear like the above example. The raw portion indicates that this is a raw variable and the translation between $myplugin_output and {vb:raw myplugin_output} occurs automatically.
Remember, you must still reference this variable as $myplugin_output within your plugin. It is only within the templates that the same variable needs to be referenced in the new format.
Example2
Say you store your variables as an array and one output variable within your plugin looks like $myplugin_var['output1'] or $myplugin_var[output1]. These variables are handled in the same way but with a slight variation. The following is how this same variable would be written within a vBulletin template.
{vb:raw myplugin_var.output1}
Again, you are using a raw vBulletin 4 variable. This time, the key within your array variable is called after the array name and the two are separated by a period. So these types of variables always follow the following format.
$arrayName['key'] translates to {vb:raw arrayName.key}
It's that simple. Once your get the formatting down, you will be able to reference your plugin variables without any issues just as you were able to within prior versions of vBulletin.
Part Two: http://www.vbulletin.com/forum/entry...s-to-templates
Referring to plugin variables within your vBulletin 4 templates
Collapse
X
Collapse
Related Topics
Collapse
-
by simonhindi have a question
i have a setting varname fbbadge_active_link and need to put the content of that into a template
i tried everything from
{vb:raw vboptions.fbbadge_active_link}...-
Channel: Support Issues & Questions
Wed 19 Sep '12, 3:52am -
Variable registration is discussed in the companion blog to this article. That blog entry is linked at the end of this one.
Ok, after pushing my variables into the templates as described on page two of this blog post I noticed that $myplugin_output and {vb:raw myplugin_output} both work, but not at the same time
When used individually they both work fine.
When used at the same time, once each, I would expect that the HTML within the variable to simply be echoed twice, but that is not what happens. In the case when they are both used at the same time, {vb:raw myplugin_output} works as intended, echoing the variable's HTML, while $myplugin_output simply echoes itself, "$myplugin_output"
I don't need to use both but am reporting this as it does seem to be working in an awkward way.
So, finally, when we can choose to use $myplugin_output or {vb:raw myplugin_output} within templates, which way is the correct way? Does it matter which option is used since they both work?