Using switch on Single Choice

Author Message

Eivind Marienborg

Tuesday 24 August 2004 3:22:53 pm

I need to do different things based on what is stored in a Single Choice drop down-list.

For testing, I've tried to display a simple number to indicate what switch gets used:


        {section show=$node.object.data_map.sivilstatus.content}
        {switch match=$node.object.data_map.sivilstatus}
        {case match=0}
        <tr><td class="label"><b>0Sivilstatus:</b></td><td class="element">{attribute_view_gui attribute=$node.object.data_map.sivilstatus}</td></tr>
        {/case}
        {case match=1}
        <tr><td class="label"><b>1Sivilstatus:</b></td><td class="element">{attribute_view_gui attribute=$node.object.data_map.sivilstatus}</td></tr>
        {/case}

        {case match=2}
        <tr><td class="label"><b>2Sivilstatus:</b></td><td class="element">{attribute_view_gui attribute=$node.object.data_map.sivilstatus}</td></tr>
        {/case}

        {case match=3}
        <tr><td class="label"><b>3Sivilstatus:</b></td><td class="element">{attribute_view_gui attribute=$node.object.data_map.sivilstatus}</td></tr>
        {/case}


        {case}
        <tr><td class="label"><b>4Sivilstatus:</b></td><td class="element">{attribute_view_gui attribute=$node.object.data_map.sivilstatus}</td></tr>
        {/case}
        {/switch}
        {/section}

It displays number 4 all the time - The default - Which means that none of the switches gets initaied. I've also tried matching on the text that gets output, but that doesn't seem to work either.

Any ideas?

Alex Jones

Tuesday 24 August 2004 4:12:48 pm

Perhahs try changing:

{switch match=$node.object.data_map.sivilstatus}

to

{switch match=$node.object.data_map.sivilstatus.content}

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Eivind Marienborg

Wednesday 25 August 2004 2:32:12 am

I solved it with a little workaround.. I made an override template for the ezselection.tpl (which handles the printout of the single choice), and did the switch on the plain text of the output there.

It's not the best sollution, but it works for now..

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

Main resources:

Total runtime0.7778 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 590.2734152.6250
Module start 'layout' 0.00530.0029 742.898439.4453
Module start 'content' 0.00830.7682 782.3438544.7891
Module end 'content' 0.77640.0014 1,327.132812.1641
Script end 0.7778  1,339.2969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4669160.0002
Check MTime0.00140.1751160.0001
Mysql Total
Database connection0.00090.119910.0009
Mysqli_queries0.724493.1313570.0127
Looping result0.00050.0629550.0000
Template Total0.741795.420.3708
Template load0.00190.238020.0009
Template processing0.739895.111220.3699
Template load and register function0.00010.011210.0001
states
state_id_array0.00100.130410.0010
state_identifier_array0.00120.150220.0006
Override
Cache load0.00160.2011190.0001
Sytem overhead
Fetch class attribute can translate value0.00060.071920.0003
Fetch class attribute name0.00130.161250.0003
XML
Image XML parsing0.00080.100320.0004
class_abstraction
Instantiating content class attribute0.00000.005060.0000
General
dbfile0.00630.8141220.0003
String conversion0.00000.001440.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs