Forums / Developer / using arrays -> help needed

using arrays -> help needed

Author Message

Georg Franz

Wednesday 09 July 2003 9:29:56 am

Hi folks,

I have many related objects at an article. I want to show them in different places at the article page.

So I want to put a related object to one or more different arrays, if a statement is true.

{let main_array = array(1,2,3,2,5,4,2)
new_array = array()}
{section name=test loop=$main_array}
{section show=eq($test:item, 2)}
{set new_array[] = $test:item}
{/section}
{/section}
{/let}

This didn't work. So how could I put a new value at the end of new_array? Is there a array_merge or array_append function?

Kind regards,
Emil.

Best wishes,
Georg.

--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004

Paul Forsyth

Thursday 10 July 2003 12:57:58 am

Im not sure that you can add to arrays in this way from a template.

What kind of errors are you getting?

Jan Borsodi

Thursday 10 July 2003 6:07:30 am

The template engine does not support appending to arrays with []. Try using array append
{set new_array = $new_array|array_append($test:item)}

See the documentation for arrays for more info
http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/array_handling

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Georg Franz

Monday 14 July 2003 4:22:14 am

thanx for the info and the new documentation!

Kind regards,
Emil.

Best wishes,
Georg.

--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004