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.
<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>
This example extends the previous conditional to show a different message to registered members from that shown to guests.
<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>
<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>
Perhaps the easiest way to illustrate this is to demonstrate a simple example of PHP code being embedded as a template conditional.
Let us assume for the purposes of this example that we want to have the equivalent of this PHP code in our template:
if ($my_variable == 1)
{
echo "<p>My variable is equal to one.</p>";
}
<vb:if condition="$my_variable == 1"> <p>My variable is equal to one.</p> </vb:if>
if ($my_variable == 1)
{
echo "<p>My variable is equal to one.</p>";
}
else
{
echo "<p>My variable is not equal to one.</p>";
}
<vb:if condition="$my_variable == 1"> <p>My variable is equal to one.</p> <vb:else /> <p>My variable is not equal to one.</p> </vb:if>
if ($my_variable == 1)
{
echo "<p>My variable is equal to one.</p>";
}
else if ($my_variable == 2)
{
echo "<p>My variable is equal to two.</p>";
}
else
{
echo "<p>My variable is equal to neither one nor two.</p>";
}
<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>
if(($moo == '1') AND ($baa == '0'))
{
echo "boo";
}
can be done with
<if condition="($moo == 1) AND ($baa == 0)">
boo
</if>
<if condition="$bbuserinfo['userid'] == 0">
<p>Welcome to the forum!<br />
If this is your first visit, we hope you enjoy your stay!</p>
<else />
<p>Welcome back, $bbuserinfo[username].<br />
<a href="search.php?do=getnew">Click here to view new posts</a>.
</if>
Be:
<if condition="$bbuserinfo[userid] == 0">
<p>Welcome to the forum!<br />
If this is your first visit, we hope you enjoy your stay!</p>
<else />
<p>Welcome back, $bbuserinfo[username].<br />
<a href="search.php?do=getnew">Click here to view new posts</a>.
</if>
I got a parse error when it had those in it :S
<if condition="$GLOBALS['NoShowLoginPopup'] = 1">
But if you want to print out the global variable using the GLOBALS array in a template, use this syntax:
{$GLOBALS['NoShowLoginPopup']}
The second gives a parse error.
<if condition="($myvar_1 == 1) AND ($myvar_2 == 0)">
Operators
</if>
And the following code:
<if condition="$myvar_1 == 1 AND $myvar_2 == 0">
Operators
</if>
Both ones executes fine. Please note that you can use logical operators like this:
<if condition="($myvar_1 == 1) || ($myvar_2 == 0)">
Operators
</if>
Or:
<if condition="$myvar_1 == 1 || $myvar_2 == 0">
Operators
</if>
http://forum.vbulletinsetup.com/f18/vbulletin-template-conditionals-list-2185.html
http://www.vbulletin.com/forum/showthread.php?p=1728240#post1728240
To find out if the user browsing the forum is in a certain usergroup then use this:
<if condition="is_member_of($bbuserinfo,2,8,10,11) ">
To find out if the poster is in a certain usergroup then use this:
<if condition="is_member_of($post,2,8,10,11)">
I had to do as below:
<vb:if condition="$show['threadinfo'] == 1">
<p>threadinfo</p>
<vb:else />
<vb:if condition="$show['foruminfo'] == 1">
<p>foruminfo</p>
<vb:else />
<p>forumhome</p>
</vb:if>
</vb:if>