Forums / General / hash() - creating associative array
Łukasz Serwatka
Thursday 16 December 2004 2:18:37 am
Hi
I would like to creat associative array.
array( 1 => 'one', 2 => 'two', 3 => 'three' )
{let class_attribute=fetch( 'content', 'class_attribute', hash( 'attribute_id', 244 ) ) att_values} {section loop=$class_attribute.content.options} {set att_values=hash($:item.id, $:item.name)} {/section} {$att_values|attribute(show)} // show only 4 string 'value 4' - last value {/let}
Attribute 244 is ezselection datatype.
The output should be:
Attribute Type Value 0 string 'value 0' 1 string 'value 1' 2 string 'value 2' 3 string 'value 3' 4 string 'value 4'
Personal website -> http://serwatka.net Blog (about eZ Publish) -> http://serwatka.net/blog
Thursday 16 December 2004 3:46:58 am
Solution ... Thanks to xbit from official $Exponential IRC channel for concat suggestion ;-)
{let class_attribute=fetch( 'content', 'class_attribute', hash( 'attribute_id', 244 ) ) att_values=hash()} {section loop=$class_attribute.content.options} {set att_values=$att_values|append(concat($:item.name))} {/section} {section loop=$att_values var=myvar} {$myvar} {/section} {/let}