asleep at the Switch

Author Message

James Ward

Monday 05 May 2003 2:32:05 pm

I am having trouble with a switch statement. I am attempting to clean up my Multiple Page Article How-To by only having it display the page numbers if there is more than one page.

Currently this shows page numbers regardless of whether there are more than one:

{* Subpages *}
<table width="100%">
<td valign="top">
<h2>Pages</h2>
<a href={concat("/content/view/full/",$node.node_id,"/")|ezurl}>Page 1</a> |
{section name=Page loop=$page_list}
<a href={concat("/content/view/full/",$Page:item.node_id,"/")|ezurl}>{$Page:item.name|wash}</a> |
{/section}
</td>
</table>

I thought I could make this a little more intelligent by adding a switch which whould check the number of elements in the $page_list array and decide if it needed to display page numbers. Here is what I have:

{switch match=count($page_list)}
{case match=0)}
{/case}
{case}
{* Subpages *}
<table width="100%">
<td valign="top">
<h2>Pages</h2>
<a href={concat("/content/view/full/",$node.node_id,"/")|ezurl}>Page 1</a> |
{section name=Page loop=$page_list}
<a href={concat("/content/view/full/",$Page:item.node_id,"/")|ezurl}>{$Page:item.name|wash}</a> |
{/section}
</td>
</table>
{/case}
{/switch}

Is there a not-equal operator available for case? I do not like have to use
{case match=0}
{/case}
Just to get to the point where I know it is not-equal to zero. I tried != and <> to no avail.

I apologize if this is in the documentation somewhere and I just haven't found it but I really did look. It just seems to me that there must be a better why.

Thanks in advance.

working at www.wardnet.com
blogging at www.jamesward.ca

Zinistry Vacana

Monday 05 May 2003 2:52:37 pm

.

James Ward

Monday 05 May 2003 7:54:17 pm

Man do I feel dumb.
Right there in the documentation looking at me.

{case match=not(0)}
{/case}

Anyone else looking for a full list of logical operators can find them at
http://www.ez.no/sdk/ref/view/class/eZTemplateLogicOperator#_details

working at www.wardnet.com
blogging at www.jamesward.ca

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 30 2025 00:54:08
Script start
Timing: Jan 30 2025 00:54:08
Module start 'layout'
Timing: Jan 30 2025 00:54:08
Module start 'content'
Timing: Jan 30 2025 00:54:09
Module end 'content'
Timing: Jan 30 2025 00:54:09
Script end

Main resources:

Total runtime0.0186 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.1250151.2109
Module start 'layout' 0.00430.0024 739.335936.6484
Module start 'content' 0.00670.0106 775.984490.1250
Module end 'content' 0.01720.0013 866.109433.9922
Script end 0.0186  900.1016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002111.4014140.0002
Check MTime0.00105.4063140.0001
Mysql Total
Database connection0.00063.304110.0006
Mysqli_queries0.002513.277930.0008
Looping result0.00000.047510.0000
Template Total0.00105.110.0010
Template load0.00073.998010.0007
Template processing0.00021.091510.0002
Override
Cache load0.00052.630710.0005
General
dbfile0.006233.134580.0008
String conversion0.00000.032140.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