Log in

View Full Version : template condition that checks if a field is blank


Scathefire
03-29-2007, 08:15 PM
I currently have a condition in the postbit template that shows a link under the username, with the URL having a user's name placed at the end of it:


<if condition="is_member_of($post, 17) OR is_member_of($post, 18) OR is_member_of($post, 6)">
<a class="smallfont" target="_blank" href="http://url.com?address=$post[musername]">Linky</a>
</if>

Is there a way I could "link" it with another condition that checks to see if they left a profile field blank?

What I am trying to do is have it check to see if a particular (field7) profile field isn't blank. If there IS something in it, then append it to the end of the URL instead of the username. On the other hand, if it IS blank, then grab the username instead and append it to the end of the URL without the field's value (because it is blank anyway).

RedTyger
03-29-2007, 08:40 PM
<if condition="is_member_of($post, 17) OR is_member_of($post, 18) OR is_member_of($post, 6)">
<if condition="$userinfo[field1] == ''">
<a class="smallfont" target="_blank" href="http://url.com?address=$userinfo[field1]">Linky</a>
<else />
<a class="smallfont" target="_blank" href="http://url.com?address=$post[musername]">Linky</a>
</if>
</if>

WetWired
03-29-2007, 08:58 PM
You probably don't want to use $post[musername], use $post[username] instead. $post[musername] contains usergroup markup (ie. bold tags for staff).

Scathefire
03-30-2007, 01:24 AM
Ok, I had to change a little from the above example:


<if condition="is_member_of($post, 17) OR is_member_of($post, 18) OR is_member_of($post, 6)">
<if condition="$post[field7] != ''">
<a class="smallfont" target="_blank" href="http://url.com?address=$post[field7]">Linky</a>
<else />
<a class="smallfont" target="_blank" href="http://url.com?address=$post[username]">Linky</a>
</if>
</if>

Thanks for the assistance, it is working perfectly now.