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.
<if condition="$bbuserinfo['userid'] == 0">
<p>Welcome to the forum!<br />
If this is your first visit, we hope you enjoy your stay!</p>
</if>
This example extends the previous conditional to show a different message to registered members from that shown to guests.
<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>
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>";
}
<if condition="$my_variable == 1">
<p>My variable is equal to one.</p>
</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>";
}
<if condition="$my_variable == 1">
<p>My variable is equal to one.</p>
<else />
<p>My variable is not equal to one.</p>
</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>";
}
<if condition="$my_variable == 1">
<p>My variable is equal to one.</p>
<else />
<if condition="$my_variable == 2">
<p>My variable is equal to two.</p>
<else />
<p>My variable is equal to neither one nor two.</p>
</if>
</if>

if(($moo == '1') AND ($baa == '0'))
{
echo "boo";
}
can be done with
<if condition="($moo == 1) AND ($baa == 0)">
boo
</if>
<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']}
<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
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>