Forums / General / Check eq for several values in one section show

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Check eq for several values in one section show

Author Message

Valentin Svelland

Monday 27 October 2003 5:51:01 am

Is it possible to make one 'section show' check if equal on multiple values? (I'd like to do something like this - look under). Or do I have to write a section show for each and every value?

{section show=$node.node_id|eq(1124|1156|1157|1152|etc)}
<h1>Members</h1>
{/section}

Paul Forsyth

Monday 27 October 2003 5:57:20 am

See:

http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/logical_handling

You could write:

{let x=$node.node_id}

{section show=or( $x|eq(1124), $x|eq(1156), $x|eq(1157) )}
<h1>Members</h1>
{/section}

{/let}

I used a {let} to simplify the code. Take a look at the documentation for other examples.

paul

Valentin Svelland

Monday 27 October 2003 6:59:58 am

Thanks Paul! :)

Paul Forsyth

Monday 27 October 2003 7:03:40 am

Just remembed a better way :)

{switch match=$node.node_id}
{case in=array(1124,1156,1157,1152)}
<h1>Members</h1>
{/case}
{/switch}

Might be better depending on what you want to do but the code is far neater.

paul

Valentin Svelland

Wednesday 29 October 2003 12:50:39 am

Thanks again, Paul!!! :D

Jan Borsodi

Wednesday 29 October 2003 2:39:24 am

You can also use the contains operator to see if a value exists in an array.

{section show=array(1124,1156,1157)|contains($x)}
<h1>Members</h1>
{/section}

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Paul Forsyth

Wednesday 29 October 2003 2:49:48 am

Of course, much neater!

paul