![]() |
Template Conditionals IF
Template Conditionals
Template Conditionals are a powerful tool for controlling the XHTML output from your templates. They allow you to create simple if/else branches within your templates, in order to display different content depending on the condition you specify. For example you may want to show a different welcome message on the front page of your board to registered users and to guests. The way to know whether or not the person visiting a page is a guest, or a logged-in user is to check the value of $bbuserinfo[userid]. If the value is 0, the visitor is a guest (or not logged-in), otherwise the visitor is a registered member. This is a simple conditional to show a welcome message to guests only. Code:
<vb:if condition="$bbuserinfo['userid'] == 0">This example extends the previous conditional to show a different message to registered members from that shown to guests. Code:
<vb:if condition="$bbuserinfo['userid'] == 0">Code:
<vb:if condition="$my_variable == 1"><vb:if condition="THIS_SCRIPT == 'index'"> <p>My variable is equal to one.</p> <vb:else /> <p>My variable is not equal to one.</p> </vb:if> <if condition="THIS_SCRIPT == 'index'"> </if> |
| All times are GMT +8. The time now is 10:54 AM. |
Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.