Forums / Developer / Using switch on Single Choice
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>
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..