Help with xen:if coding in template

bashy

Member
Hi,

I'm working on the userpanel template files and wanted to do something nice with the alerts you get.
So I've got the code nearly done but I need to add different CSS classes depending on if the user has an unread alert or not.

Here is a part of the code I used from the default template on XenForo;
Code:
<a href="{xen:link account/alerts}" class="{xen:if {$visitor.alerts_unread}, '', 'noalert'}">
  {xen:number $visitor.alerts_unread}
</a>

So that would spit out the class "noalert" if unread is empty.
I want to add another class for if the user has an alert but I don't know the xen code enough to do it. I can do it fine in PHP :P

PHP:
if($visitoralerts_unread != '0') {
echo 'alert';
}
 
You already have the conditional structure there. It's an "if else" logic. If true then value, else next value.

Rich (BB code):
<a href="{xen:link account/alerts}" class="{xen:if {$visitor.alerts_unread}, 'alert', 'noalert'}">
  {xen:number $visitor.alerts_unread}
</a>
 
You already have the conditional structure there. It's an "if else" logic. If true then value, else next value.

Rich (BB code):
<a href="{xen:link account/alerts}" class="{xen:if {$visitor.alerts_unread}, 'alert', 'noalert'}">
  {xen:number $visitor.alerts_unread}
</a>
Oh! I think I got confused at what , ' ', ' ' was doing :p
Many thanks!

What I got now :)
tU0t


Is there a guide to all of these xen codes? Also a list of variables available?
 
Top Bottom