Pls help to correct the code

Author Message

SathishKumar Subramanian

Thursday 18 December 2003 4:10:21 am

Hi,

I am using the following code. In this code, If either the total count of resources or the articles count greater than 0 then I am trying to publish the html content in the switch condition. If the resource count is greater than 0 then I want to publish the Message 1. Similarly if the articles count greater than 0 then I want to publish the Message 2.

The {switch match=$:totRes:totalResources} condition is not checking the required validation. So I am getting the Message 1 and 2 in all conditions eventhough total resources or total articles are 0.

The code is:

{*Get total Count of Study Materials*}
{let name=totRes totalResources=fetch('content','list_count', hash('parent_node_id',$node.node_id,'class_filter_array',array(17),'class_filter_type','include'))}

{*Get total Count of Articles*}
{let name=totArt totalArticles=fetch('content','list_count', hash('parent_node_id',$node.node_id,'class_filter_array',array(2),'class_filter_type','include'))}

{section show=(or(gt($totRes:totalResources,0),gt($totRes:totArt:totalArticles,0)))}
<table><tr><td>Hello Everybody!</td></tr></table>

{switch match=$:totRes:totalResources}
{case match=gt(0)}
<table><tr><td>Message 1 </td></tr></table>
{/case}
{/switch}

{switch match=$:totRes:totArt:totalArticles}
{case match=gt(0)}
<table><tr><td>Message 2 </td></tr></table>
{/case}
{/switch}

{/section}
{/let}
{/let}

How can I make it to function right? Pls help.
Sathizh

Paal Are Solberg

Tuesday 30 December 2003 11:26:16 pm

Namespaces can be tricky! Good idea is to introduce fewer of them by 1) grouping more of the "fetch'es" together at the top in the first "let" and 2) working more on your algorithm. Try the code below (I have not tested this, but it may give you some ideas)?

{*Get total Count of Study Materials*}
{let totalResources=fetch('content','list_count', hash('parent_node_id',$node.node_id,
'class_filter_array',array(17),'class_filter_type','include'))

{*Get total Count of Articles*}
totalArticles=fetch('content','list_count', hash('parent_node_id',$node.node_id,
'class_filter_array',array(2),'class_filter_type','include'))}

{section show=$totalResources|gt(0)}
<table><tr><td>Hello Everybody!</td></tr></table>
<table><tr><td>Message 1 </td></tr></table>
{section-else}
{section show=$totalArticles|gt(0)}
<table><tr><td>Hello Everybody!</td></tr></table>
table><tr><td>Message 2 </td></tr></table>
{/section}
{/section}
{/let}

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 19 2025 06:07:04
Script start
Timing: Jan 19 2025 06:07:04
Module start 'layout'
Timing: Jan 19 2025 06:07:04
Module start 'content'
Timing: Jan 19 2025 06:07:04
Module end 'content'
Timing: Jan 19 2025 06:07:04
Script end

Main resources:

Total runtime0.6775 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 589.1563152.6250
Module start 'layout' 0.00460.0029 741.781339.4453
Module start 'content' 0.00740.6687 781.2266475.5625
Module end 'content' 0.67610.0014 1,256.789112.1641
Script end 0.6775  1,268.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4632160.0002
Check MTime0.00120.1826160.0001
Mysql Total
Database connection0.00070.104210.0007
Mysqli_queries0.631193.1430540.0117
Looping result0.00050.0722520.0000
Template Total0.651496.120.3257
Template load0.00190.274720.0009
Template processing0.649695.870320.3248
Template load and register function0.00020.024910.0002
states
state_id_array0.00060.090010.0006
state_identifier_array0.00080.123020.0004
Override
Cache load0.00160.2383460.0000
Sytem overhead
Fetch class attribute can translate value0.00070.107520.0004
Fetch class attribute name0.00100.145420.0005
XML
Image XML parsing0.00030.037520.0001
class_abstraction
Instantiating content class attribute0.00000.000920.0000
General
dbfile0.00140.2087100.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs