Switch / case - multiple check

Author Message

Bjørn Kaarstein

Friday 30 April 2004 2:01:23 am

Is it possible to shrink this code:

{case match=343} 
{/case}
{case match=136} 
{/case}
{case match=141} 
{/case}
{case match=142} 
{/case}
{case match=192} 
{/case}
{case match=193} 
{/case}
{case match=194} 
{/case}
{case match=195} 
{/case}

into something like:

{case match=343,136,141,142,192,193,194,195} 
{/case}

The last example doesn't work, but something in this style keeps it much cleaner...

Regards Bjørn

Paul Forsyth

Friday 30 April 2004 2:10:48 am

Sure:

{section show=array( 343,136,141,142,192,193,194,195 )|contains( $node.node_id )}
 
{/section}

paul

--
http://www.visionwt.com

Ole Morten Halvorsen

Friday 30 April 2004 2:17:36 am

or you can do it like this:

{case in=array( 343,136,141,142,192,193,194,195 )}
{/case}

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Bjørn Kaarstein

Friday 30 April 2004 2:25:58 am

Thanks!

Works like a charm.

Regards Bjørn

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.