Problem with the switch command

Author Message

Aleksandar Adam

Wednesday 04 January 2006 7:18:47 am

I have a class "projekt" med attribute "typ". "typ" is choice list with two values "Teknik" and "Organisation". My code doesn't recognise "Teknik" or "Organisation" values, it only executes default part of the switch command.

I think that I need to pick up the correct value which is stored in the $Child:item.object.data_map.typ so I can get "Teknik" or "Organisation" but I don't know which attribute to use. Any suggestions?

Any answer is appreciated.

{switch match=$Child:item.object.data_map.typ}

{case match='Teknik'}
Teknik
{/case}

{case match=' Organisation'}
Organisation
{/case}

{case}
DEFAULT
{/case}

{/switch}

Patrice DUCLAUD

Wednesday 04 January 2006 11:26:47 pm

you can perhaps try

{switch match=$Child:item.object.data_map.typ.content}

Patrice

Aleksandar Adam

Thursday 05 January 2006 1:50:27 pm

It didn't help because

$Child:item.object.data_map.typ.content

is an array - you can't match two values in the same time, and what I need is to get the value of the item selected in that array (...."typ")

If I can get some help how to use

input|attribute( [show_values [, level [, table ] ] ] )

maybe I can solve the problem. That what I don't understand is the "level" value and when you get result output what does it mean those ">" or ">>" or ">>>" and how to read the output ?

Bruce Morrison

Thursday 05 January 2006 3:23:13 pm

Howdy Aleksandar

Adding

{$Child:item.object.data_map.typ|attribute( show,2 )}

to your template will give you some information about the attribute.

The level parameter indicates the number of levels to traverse and display in the attribute.

This thread may give you some clues
http://ez.no/community/forum/general/ezselection_how_to_display_data/re_ezselection_how_to_display_data__2

HTH

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Aleksandar Adam

Friday 06 January 2006 8:53:21 am

It really helped to solve my problem.
Thanks!

Aleksandar Adam

Sunday 19 March 2006 9:03:05 am

1. I have read the article which Bruce suggested:
http://ez.no/community/forum/general/ezselection_how_to_display_data/re_ezselection_how_to_display_data__2

I have an object with multiple choice list which is called "status" and I use the following in my code to get value of "status":

$Child:item.object.data_map.status.contentclass_attribute.content.options[$Child:item.object.data_map.status.content[0]].name

I have the following values in status: 0%,20%,60%,80%,100%, it is multiple choice list.

When I want to test status to see which value is there it shows 80% when I have chosen 60%, 100% when I have chosen 80% and " " when it is 100%

In other words values are changed (or moved on some way),

Why?

2. there is a documentation page about getting the values from the chosen elements from the objects in multiple choice lists like in the preceding example but I cant find it, does anybody know where it is?

Thanks in advance.
Aleksandar

Kristof Coomans

Sunday 19 March 2006 10:44:51 am

Maybe the comments in this thread can help you:
http://ez.no/community/forum/developer/image_link_question/

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Aleksandar Adam

Sunday 19 March 2006 11:17:28 am

This guy Niklas in thread you suggested is my working mate and it seems your answer it didn't helped him, so I need some other piece of advice, but thanks anyway.

Kristof Coomans

Sunday 19 March 2006 11:21:21 pm

Can you give me the results of:

{$Child:item.object.data_map.status.contentclass_attribute.content.options|attribute(show)}

(place this right before the image)

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Niklas Gunnäs

Monday 20 March 2006 12:50:37 am

Hi Kristof,

Thanks again for your help

And the result is....

0 array Array(2)
>id string 0
>name string 00
1 array Array(2)
>id string 1
>name string 10
2 array Array(2)
>id string 2
>name string 20
3 array Array(2)
>id string 4
>name string 30
4 array Array(2)
>id string 5
>name string 40
5 array Array(2)
>id string 6
>name string 50
6 array Array(2)
>id string 7
>name string 60
7 array Array(2)
>id string 8
>name string 70
8 array Array(2)
>id string 9
>name string 80
9 array Array(2)
>id string 10
>name string 90
10 array Array(2)
>id string 11
>name string 100

We made it work by rename the images so that wrong value we get back shows the right image if you get what I mean.

Kristof Coomans

Monday 20 March 2006 1:47:37 am

Since the fourth index of your array (3), the option id's aren't the same as the array index. This is a situation like I described in the other thread.

Did you get any errors/warnings in the debug output when using the code I supplied in the other thread?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Niklas Gunnäs

Monday 20 March 2006 3:43:07 am

I dont get it.... :-(

I understand that image showed will be incorrect from array3. But what I cant understand is why {attribute_view_gui attribute=$Child:item.object.data_map.status} always show the correct value. If it was possible to use

<img src={concat(status, attribute_view_gui attribute=$Child:item.object.data_map.status, ".gif")|ezimage}> {attribute_view_gui attribute=$Child:item.object.data_map.status}%

it would show correct image for example status40.png and 40%

Used your exempel but it returned a list of all images and showing the correct value after.

Is there not a better way then this

$Child:item.object.data_map.status.contentclass_attribute.content.options[$:item.object.data_map.status.content[0]].name

to get the value from status

Betsy Gamrat

Monday 20 March 2006 9:56:28 am

What about an array that maps the indexes to the correct values?

For example:

{def $mapper=hash( 0, '00', 1, '10', 2, '20', 4 ,'30' , 5, '40' ... )}

{set $num=$mapper[$id]}

where $id is the data stored in the attributes of the object.

It might be worth redefining that attribute so the ids match the names better.

Kristof Coomans

Monday 20 March 2006 12:05:57 pm

There was a little error in my template code (posted a new version in the other topic).

{attribute_view_gui attribute=$Child:item.object.data_map.status} uses another template, design/standard/templates/content/datatype/view/ezselection.tpl. It uses the same method to get the correct value as I mentioned, but with some older template syntax.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

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 18 2025 16:20:43
Script start
Timing: Jan 18 2025 16:20:43
Module start 'layout'
Timing: Jan 18 2025 16:20:43
Module start 'content'
Timing: Jan 18 2025 16:20:44
Module end 'content'
Timing: Jan 18 2025 16:20:44
Script end

Main resources:

Total runtime0.9496 sec
Peak memory usage4,096.0000 KB
Database Queries98

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 587.9141152.6250
Module start 'layout' 0.00530.0034 740.539139.4609
Module start 'content' 0.00870.9394 780.0000846.2422
Module end 'content' 0.94810.0014 1,626.242232.1641
Script end 0.9495  1,658.4063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.3952160.0002
Check MTime0.00170.1767160.0001
Mysql Total
Database connection0.00070.071910.0007
Mysqli_queries0.808485.1354980.0082
Looping result0.00120.1211960.0000
Template Total0.915896.420.4579
Template load0.00260.277120.0013
Template processing0.913196.158820.4566
Template load and register function0.00010.010510.0001
states
state_id_array0.00130.134710.0013
state_identifier_array0.00170.176220.0008
Override
Cache load0.00260.27211370.0000
Sytem overhead
Fetch class attribute can translate value0.00150.154160.0002
Fetch class attribute name0.00220.2296190.0001
XML
Image XML parsing0.00800.846860.0013
class_abstraction
Instantiating content class attribute0.00010.0079270.0000
General
dbfile0.00650.6879400.0002
String conversion0.00000.000940.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
13content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
14content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
24content/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
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: 66
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs