XF 2.3 Conditional for nodes

  • Thread starter Thread starter Deleted member 184953
  • Start date Start date
D

Deleted member 184953

Guest
Hello, i use this code to display some content for one node:
HTML:
<xf:if is="$xf.reply.containerKey == 'node-71'">
    // content
</xf:if>
I can't find the way for multiples nodes...
I knew but i didn't know anymore... :rolleyes:
 
Ok, that's explain all... i took this conditional as an example:
HTML:
<xf:if is="in_array({$forum.node_id}, [X,Y,Z])">
Where X,Y,Z are node ID so just 34, 2, 18
 
This may annoy you ...

HTML:
<xf:if is="in_array($var, ['thing', 'other_thing'])">

Would:
HTML:
<xf:if is="$xf.reply.containerKey == 'node-71' AND $xf.reply.containerKey == 'node-72' AND $xf.reply.containerKey == 'node-73'">
be acceptable too?

I have some old templates where I use AND, not knowing about in_array() or when it came to templates (as functions aren't in the documentation).

Would in_array() perform better or would it be negligible to go back and change it now?
 
Using OR will achieve the same result but an array is much more compact and easier to read/maintain.
Thanks.

Will go back through 2.1 template edits that I've done to see what I can make more readable (as they extend pretty long with OR OR OR...).
 
Back
Top Bottom