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.

eZ debug

Timing: Jan 31 2025 01:17:00
Script start
Timing: Jan 31 2025 01:17:00
Module start 'layout'
Timing: Jan 31 2025 01:17:00
Module start 'content'
Timing: Jan 31 2025 01:17:00
Module end 'content'
Timing: Jan 31 2025 01:17:00
Script end

Main resources:

Total runtime0.0321 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.1328151.2109
Module start 'layout' 0.00530.0040 739.3438220.6875
Module start 'content' 0.00930.0208 960.0313997.8047
Module end 'content' 0.03010.0019 1,957.835933.9922
Script end 0.0320  1,991.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.009529.5254140.0007
Check MTime0.00123.8820140.0001
Mysql Total
Database connection0.00072.327410.0007
Mysqli_queries0.00226.873030.0007
Looping result0.00000.040210.0000
Template Total0.00134.110.0013
Template load0.00103.073510.0010
Template processing0.00031.045110.0003
Override
Cache load0.00072.105810.0007
General
dbfile0.00185.687380.0002
String conversion0.00000.024540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs