Associative arrays not working?

Associative arrays not working?

Thursday 07 August 2008 6:49:11 am - 3 replies

Modified on Thursday 07 August 2008 6:50:46 am by Oliver Frommel

Author Message

André R.

Thursday 07 August 2008 7:00:48 am

From the var_dump ypu can see that this is a object of type eZInformationCollectionAttribute, not a array.

The clean way to get the variable would be (this is supported by all classes that are meant to be used inside a template):

$dataInt = $attribute->attribute('data_int');

Or the regular way:

$dataInt = $attribute->DataInt;

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

Oliver Frommel

Thursday 07 August 2008 8:36:29 am

This is great, thanks.

Maybe you can also explain how I get the description of the options that are found in the content object instance belonging to the information collection? The only thing I could find was a text attribute filled with an XML fragment like this:

                // <ezoption>
                // <name>company_size</name>
                // <options>
                //    <option id="0"
                //           additional_price="0">0-10</option>
                //   <option id="1"
                //          additional_price="0">10-20</option>
                //     <option id="2"
                //          additional_price="0">20-30</option>
                //    <option id="3"
                //            additional_price="0">30-40</option>
                //   </options>
                // </ezoption>
                //

I was able to parse it but it is a bit cumbersome. I thought there was a way just looking the description up via an (associative) array?

Thanks
Oliver

André R.

Thursday 07 August 2008 9:13:55 am

Some template code for selection attribute that might help:

{def $portion_array            = $node.data_map.portions_type.content
     $portion_type             = ''}
{foreach $node.data_map.portions_type.class_content.options as $option}
    {if $portion_array|contains( $option.identifier )}{set $portion_type = $option.name|wash(xhtml)}{/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

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

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