Xen:If & Values

CFodder

Well-known member
I've tried for the life of me, prob a simple syntax error, but I can't the if statement to work with a value. Have looked at other code to see if I can figure it but to no avail.

Am trying to get an item to display if the value is larger than zero, an example of what I'm trying tdo do is:

<xen:if {xen:number $cfisaplonker} != 0>

Have tried wrapping in brackets, quotes etc but it won't let me save it as coming up with a syntax error. Any help on this would be greatly appreciated.
 
Brilliant ... thanks very much Shadab, my problem was I was leaving 'is' out, I thought that was only used when referencing usergroups, my bad.
 
Or, using the curly syntax,
Code:
{xen:if '{$cfisaplonker} > 0', 'Test'}
 
Out of interest, what's the difference between using Shadab's code with angular brackets and yours using curly brackets?
 
None, except that the curly syntax can be used inside tag attributes and maintain valid HTML:

HTML:
<p class="{xen:if $moo, 'moo', 'notMoo'}"> <!-- valid HTML -->


<p class="<xen:if is="$moo">moo<xen:else />notMoo</xen:if>"> <!-- invalid HTML -->
 
can I do the following?
Code:
{xen:if $checked == $forum.node_id, 'selected'}

This is giving me a template error.
 
can I do the following?
Code:
{xen:if $checked == $forum.node_id, 'selected'}

This is giving me a template error.
The condition needs quotes and curlies if you're including more than just a simple variable check:
Code:
{xen:if '{$checked} == {$forum.node_id}', 'selected'}
 
None, except that the curly syntax can be used inside tag attributes and maintain valid HTML:

HTML:
<p class="{xen:if $moo, 'moo', 'notMoo'}"> <!-- valid HTML -->
 
 
<p class="<xen:if is="$moo">moo<xen:else />notMoo</xen:if>"> <!-- invalid HTML -->
How come I never knew about this. Little gem. Or rather, perhaps I never realized this.
I remember having to fight a bit with tags where classes change, I will try to update those plugin templates.
 
can I do the following?
Code:
{xen:if $checked == $forum.node_id, 'selected'}

This is giving me a template error.
But you should use this for 'checked' and 'selected'

Code:
{xen:selected '{$checked} == {$forum.node_id}'}

Or

Code:
{xen:checked '{$checked} == {$forum.node_id}'}
 
<div class="{xen:if '{$news.thread_id%2}', 'primaryContentDark', 'primaryContent'}">

can any of you tell me if this is correct or point me in the direction i should be going.

basically i want if the news thread id is ODD use primarycontent dark, else use primary content.
 
<div class="{xen:if '{$news.thread_id%2}', 'primaryContentDark', 'primaryContent'}">

can any of you tell me if this is correct or point me in the direction i should be going.

basically i want if the news thread id is ODD use primarycontent dark, else use primary content.
Should be

Code:
{xen:if '{$news.thread_id} % 2 == 1', 'primaryContentDark', 'primaryContent'}
 
None, except that the curly syntax can be used inside tag attributes and maintain valid HTML:

HTML:
<p class="{xen:if $moo, 'moo', 'notMoo'}"> <!-- valid HTML -->


<p class="<xen:if is="$moo">moo<xen:else />notMoo</xen:if>"> <!-- invalid HTML -->
is it supported in xF2.1?

I changed xen to xf but I still have all {xf:if ...} content in my class
 
Top Bottom