Share » Forums » Setup & design » Problem with the switch command

Problem with the switch command

Problem with the switch command

Wednesday 04 January 2006 7:18:47 am - 13 replies

Modified on Wednesday 04 January 2006 9:32:56 am by Aleksandar Adam

Author Message

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

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu