vBulletin 4 Template Syntax: General
The content of this article is also available in your vBulletin distribution in ./readme-syntax.html.
vBulletin 4 Template Syntax vBulletin 4.0 introduces a rich new syntax for marking-up templates, reducing the need for formatting and escaping to be performed in .php files. Note that once a template makes use of any vBulletin 4 template syntax, the old syntax will cease to operate for that template. Conversions must be an all-or-nothing affair. Variable Access Safe Variables Going forward, variables should be referenced in templates wherever possible using the following syntax: HTML Code:
{vb:var variable} To access array elements, use a dot operator, rather than standard PHP square brackets: HTML Code:
{vb:var variable.foo} // accesses htmlspecialchars($variable['foo']) To access variables in the normal, pre-vB4 fashion, use the following syntax: HTML Code:
{vb:raw variable} This is equivalent to simply accessing $variable in the pre-vB4 syntax. No treatment is applied to the variable. The same dot operator is used to access array elements. Curly-Brace Syntax The general syntax here is HTML Code:
{vb:method arg1[, arg2...]} HTML Code:
{vb:method {variable}} // unneccessary extra braces HTML Code:
[font=Consolas]{vb:method variable}[/font] phrase HTML Code:
{vb:phrase phrase_name[, arguments for phrase...]} rawphrase HTML Code:
{vb:rawphrase phrase_name[, arguments for phrase...]} Example: HTML Code:
{vb:rawphrase message_by_x_on_y_at_z, {vb:link member, {vb:raw postinfo}}, {vb:raw postinfo.username}, {vb:raw postinfo.postdate}, {vb:raw postinfo.posttime}} date HTML Code:
{vb:date timestamp[, format]} time HTML Code:
{vb:time timestamp[, format]} number HTML Code:
{vb:number number[, decimals]} raw HTML Code:
{vb:raw variable} escapejs HTML Code:
{vb:escapejs variable} urlencode HTML Code:
{vb:urlencode variable} if HTML Code:
{vb:if condition, true[, false]} link HTML Code:
{vb:link type, info[, extra-info]} math HTML Code:
{vb:math expression} stylevar HTML Code:
{vb:stylevar name[.sub-part]} Tags All tags make use of the vb namespace for ease of identification and parsing. The following tags are available: literal HTML Code:
<vb:literal>misc code</vb:literal> if HTML Code:
<vb:if condition="condition">true result</vb:if> elseif HTML Code:
<vb:elseif condition="condition" />true result else HTML Code:
<vb:else />true result comment HTML Code:
<vb:comment>a comment</vb:comment> each HTML Code:
<vb:each from="array" key="key" value="value"></vb:each> Example Use of vb:each PHP Code:
|
Some more verbose documentation of the new link-method would really be appreciated. For which types of pages is it operative, and what parameters can or have to be provided?
|
Note that for "each" , the key part (in red) is optional.
Code:
<vb:each from="array" key="key" value="value">/*Do Something*/</vb:each> |
Has to be the worst template documentation ever. Basically this doc is a waste of time since there is soo little information in it. Not helpful what so ever, more of a hindrance since I wasted my time reading it instead of looking for a better resource. I would suggest you check out the Smarty template eninge's docs for what helpful docs look like.
|
Thanks Marco for taking the time to write this for us. I found it quite helpful.
|
Quote:
In the meantime, I found this helpful, thank you for writing it. |
Quote:
Quote:
Quote:
Quote:
|
I've tried multiple ways, but cannot seem to get it to output at all.
I'm trying to get some of the site stats variables from here to display, but to no avail. I've tried a few ways... PHP Code:
Thanks |
1 or 3, depending on what's in the variable. But I doubt that that variable is available in globally, so you'd probably make a plugin to fill it and register it for the template you want to use it in.
|
Oh, okay. But I thought the variables listed in the vBulletin variable list (https://vborg.vbsupport.ru/showthread.php?t=179930) were global.
|
No, the site statistics variables were never globally available in vB3, plus: you're using vB4, as it seems, and there have been some significant changes on what is available where.
|
While studying vb code is quite challenging and fun but at the same time this forum or vb itself is pathetic. Almost zero docs even for paying members. Woot!
|
All times are GMT. The time now is 12:21 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|