View Full Version : if else statement
hurricane_sh
12-11-2009, 07:37 PM
Can anyone please tell me why this code can't pass template check? Thanks!
<if condition="$userinfo['field5']">
<div class="smallfont">
<if condition="$userinfo['field6']">
$userinfo['field6']
<else />
Recent Blog:
</if>
<a href="$blogLink" target="_blank">$blogTitle</a>
</div>
</if>
Lynne
12-11-2009, 07:52 PM
What is a "template check". And what template are you putting that in?
hurricane_sh
12-12-2009, 06:17 AM
Thanks for your reply. I added it to MEMBERINFO, when I saved the template, it gave me an error message - possibly incorrect if statement.
The following code works well:
<if condition="$userinfo['field5']">
<div class="smallfont">
Recent Blog:
<a href="$blogLink" target="_blank">$blogTitle</a>
</div>
</if>
I want to add an condition for 'recent blog', but I can't get rid of the grammar error.
<if condition="$userinfo['field5']">
<div class="smallfont">
<if condition="$userinfo['field6']">
$userinfo['field6']
<else />
Recent Blog:
</if>
<a href="$blogLink" target="_blank">$blogTitle</a>
</div>
</if>
The problem is the line with $userinfo['field6'] (not the one in the condition). I think it follows the same rules as php parsed strings (http://us2.php.net/manual/en/language.types.string.php#language.types.string.pa rsing), so you can either use $userinfo[field6] or {$userinfo['field6']}
hurricane_sh
12-12-2009, 12:20 PM
Yes, it's fixed the error. Thank you so much!!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.