网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > vBulletin技术交流
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

vBulletin技术交流 主要讨论vBulletin的安装使用、模板风格、插件以及小技巧等。

Reply
 
Thread Tools Display Modes
  #1   IP: 112.87.0.239
Old 2013-05-06, 07:52 AM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default 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">
    <p>Welcome to the forum!<br />
    If this is your first visit, we hope you enjoy your stay!</p>
</vb:if>
The previous example used a simple 'if' condition. We can extend that to include an 'else' condition, which will be used if the 'if' condition is not fulfilled.

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">
    <p>Welcome to the forum!<br />
    If this is your first visit, we hope you enjoy your stay!</p>
<vb:else />
    <p>Welcome back, $bbuserinfo[username].<br />
    <a href="search.php?do=getnew">Click here to view new posts</a>.
</vb:if>
Starting in vBulletin 4.0 template conditionals natively support 'else if' as well.

Code:
<vb:if condition="$my_variable == 1">
    <p>My variable is equal to one.</p>
<vb:elseif condition="$my_variable == 2" />
    <p>My variable is equal to two.</p>
<vb:else />
    <p>My variable is equal to neither one nor two.</p>
</vb:if>
Sample:

<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>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Install an Zen Cart Template topvip ZenCart 0 2009-08-23 05:35 PM
zen cart定制 zen cart二次开发 car ZenCart 0 2009-08-21 01:11 AM
How do I create a new template in Vbulletin? topvip vBulletin技术交流 0 2009-07-12 12:54 PM
x-cart Template Editing Guide for 4.1.x topvip X-Cart 0 2009-04-15 11:42 PM
Template Editing Guide for 4.1.x topvip X-Cart 0 2009-03-10 08:12 AM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:56 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.