How to get attribute value for a current class

Author Message

Andrei Popa

Saturday 14 March 2009 2:13:57 pm

Hello,

I created an attribute with identifier "color" and datatype: 'selection' for every class.

I try to find out what is the solution to get value for this attribute which is present in all classes.

Example: If current class is Folder and have attribute 'color' selected "Blue" i have to keep the "Blue" string value in one variable.

<b>I have to define this variable in pagelayout.tpl.</b>

Until now i find out how to get the list with attributes of the current class.

{def $attributes=fetch( 'content', 'class_attribute_list', hash( 'class_id', $content_info.class_id ) )}

Any suggestion how to do this?

Sorry for my bad english.

Many thanks,

Andrei

What do I do?! What do I do?!?

André R.

Sunday 15 March 2009 4:19:07 am

Why are you fetching the class and not the node?

{def $color_array = $node.data_map.color.content}
            {foreach $node.data_map.color.class_content.options as $option}
                {if $color_array|contains( $option.identifier )}<span>{$option.name|wash('xhtml')}</span>{/if}
            {/foreach}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Andrei Popa

Sunday 15 March 2009 1:40:46 pm

Thanks for reply.

I tried your suggestion and is not work .

Very strange ... i tried to see in pagelayout.tpl in what is contain

{$node|attribute('show')}

and i get "Attribute Type Value".

I see that "$node" is not work in pagelayout.tpl

Any suggestion ?

What do I do?! What do I do?!?

André R.

Sunday 15 March 2009 2:38:08 pm

you need to fetch it first.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Andrei Popa

Sunday 15 March 2009 2:55:36 pm

I found the solution to get selected value from a selection (single selection) datatype.

{def $node=fetch( 'content', 'node', hash( 'node_id', $current_node_id ) )}
{$node.data_map.color.class_content.options[$node.data_map.color.data_text].name}

where $current_node_id = $module_result.path[$module_result.path|count|dec].node_id

Thank you very much for your help.
Andrei

What do I do?! What do I do?!?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.