Share » Forums » Developer » Test for Single Choice

Test for Single Choice

Test for Single Choice

Friday 15 September 2006 3:31:38 am - 4 replies

Author Message

Claudia Kosny

Friday 15 September 2006 3:53:20 am

Hello David

Have a look at the attribute in question with
{$newsFeatured.object.data_map.featured|attribute('show', 2)}

There you will probably see that you are interested in the content of this attribute so fetch this one and inspect it the same way. There you can see what you have to compare with, most likely it is the number of the selected option. If you used a selectbox, the content contains an array where you have to fetch the first item if I remeber correctly.

Greetings from Luxembourg

Claudia

David Jones

Friday 15 September 2006 5:57:25 am

Thanks for your help claudia

{$newsFeatured.object.data_map.featured.content|attribute('show', 2)}

Outputs

Attribute 	Type 	Value
0 	           string 	1
Attribute 	Type 	Value
0 	           string 	0
Attribute 	Type 	Value
0 	           string 	1

So i've tried

{if eq($newsFeatured.object.data_map.featured,0)}
{if eq($newsFeatured.object.data_map.featured.content,0)}
{if eq($newsFeatured.object.data_map.featured.content|attribute,0)}

Interestingly the last one outputs all 3. The others have no output.

I just want to output the one with value 0.

Thanks again

Claudia Kosny

Friday 15 September 2006 8:00:50 am

Hi David

Does this
{$newsFeatured.object.data_map.featured.content|attribute('show', 2)}
output all 3 lines or just one for each time you call it up?
I hope it is the latter as otherwise I am not sure what datatype you use.

I will assumethat the output is just one of these lines.

Attribute       Type    Value
0                 string       1

This means that your attribute has an array as content which has one entry. This entry has the key 0, the value is of type string and has the content 1 (or 0 in one of your other lines).
This number is the key of your selection (basically the number of the entry in the selection counted zero based). If you would have a checkbox 1 would mean that it is selected, 0 not selected (although in case you would not have an array as content of the attribute but the number itself)

So to properly compare you have to access the first entry of this array. You can do that like this:

{$newsFeatured.object.data_map.featured.content[0]}

This is what you have to compare with.

Greetings

Claudia

David Jones

Friday 15 September 2006 8:57:25 am

Thanks again,

That was spot on, problem solved

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

36 542 Users on board!

Forums menu