![]() |
|
Article Options |
vBulletin 4 Template Syntax: General
by
![]() 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:
Variables accessed in this manner are 'made safe' by being run through htmlspecialchars as they are output. To access array elements, use a dot operator, rather than standard PHP square brackets:
Raw Variables To access variables in the normal, pre-vB4 fashion, use the following syntax:
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
Inside curly braces, variables can be accessed without using a separate set of surrounding braces. For example,
Built-in Methods phrase
Inserts the specified phrase. If arguments are provided, they will be run through htmlspecialchars. rawphrase
As above, though arguments bypass htmlspecialchars. Example:
date
Formats a UNIX timestamp using the default date format for the active language. A format may also be explicitly specified. Timezone will be corrected for the viewing user. time
As above, though uses the default time format instead of date format. number
Outputs a number having run through vb_number_format for correct locale formatting. Number of decimal places to display can be optionally specified. raw
Outputs the variable raw, without any formatting or escaping. escapejs
Returns the variable prepared for use as a Javascript single-quoted string instead of running htmlspecialchars. urlencode
Escapes the variable using urlencode. if
Use this in instances where the full <vb:if> tag can not be used, such as within HTML tags. link
Used to build a hyperlink URL of the specified type and into the correct 'friendly' format. math
Primarily used within CSS, this is used to evaluate the result of the mathematical expression specified. stylevar
Used to output a style variable from the style system. No escaping is performed. Tags All tags make use of the vb namespace for ease of identification and parsing. The following tags are available: literal
Any code inside vb:literal tags will be treated as plain HTML. No curly-brace syntax or vb:tag markup will be evaluated. if
If the expression specified in condition is true, the contents of the vb:if tags will be output, otherwise nothing will be output. elseif
Used in conjunction with vb:if, this allows a secondary condition to be checked and the true result to be output if the condition is met. else
Used in conjunction with vb:if, the true result will be output if the vb:if condition failed, and so did any vb:elseif checks. comment
In cases where a comment is necessary but the usual <!-- comment --> syntax is undesirable, the vb:comment tag allows its contents to be completely removed upon compiling, so they will not be delivered to the browser. Useful for internal commenting. each
This tag will iterate through an array, in a similar manner to foreach. See the example use below. Example Use of vb:each
The following members like this post: sacobra
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Views: 9639
|
Comments |
#2
|
||||
|
||||
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?
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again. http://www.roma-antiqua.de No members have liked this post.
|
#3
|
||||
|
||||
Note that for "each" , the key part (in red) is optional.
__________________
Former vBulletin.org Staff Member
Cable Forum Please do not PM me about custom work - I no longer undertake any. Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum. No members have liked this post.
|
#4
|
||||
|
||||
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.
No members have liked this post.
|
#5
|
||||
|
||||
Thanks Marco for taking the time to write this for us. I found it quite helpful.
__________________
Please feel free to PM me about custom work, installations, and upgrades! Eclipse Records - Streetcult Street Team No members have liked this post.
|
#6
|
|||
|
|||
Originally Posted by ragarcia87
Feel free to write better documentation once you know what you're doing since you already know what good documentation is. ![]()
In the meantime, I found this helpful, thank you for writing it. No members have liked this post.
|
#7
|
||||
|
||||
Originally Posted by Trek
Yea I would write helpful documention if they paid me, everyone here seems to forget this software costs money and has mabye 4 offical plugin + template docs released for a new plugin + template system compared to the likes of wordpress which is free and has more info than the average person will be able to take in.![]()
No members have liked this post.
|
#8
|
||||
|
||||
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...
Which combo is going to work? Thanks No members have liked this post.
|
#9
|
||||
|
||||
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.
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again. http://www.roma-antiqua.de No members have liked this post.
|
#10
|
|||
|
|||
Oh, okay. But I thought the variables listed in the vBulletin variable list (http://www.vbulletin.org/forum/showthread.php?t=179930) were global.
No members have liked this post.
|
#11
|
||||
|
||||
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.
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again. http://www.roma-antiqua.de No members have liked this post.
|
#12
|
|||
|
|||
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!
No members have liked this post.
|
![]() |
«
Previous Article
|
Next Article
»
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Article Options | |
|
|
New To Site? | Need Help? |
All times are GMT. The time now is 19:15.