hash :key not available with foreach

Author Message

Bernhard Reiter

Wednesday 06 July 2005 2:21:22 am

This code works great with old template syntax.
But it seems like the key is no longer available when using foreach

{let hasharray=hash('key1','value1','key2','value2')}
<p> Hash array looping with a var:</p>
{section var=element loop=$hasharray}
key: <b>{$element.key}</b> value: <b>{$element}</b><br />
{/section}

Mikhail Chekanov

Wednesday 10 August 2005 4:11:15 am

Yes, it's not available. Keep it simple:

{foreach $hasharray as $key => $value}
key: {$key}, value: {$value}
{/foreach}

--
mike
#6595551

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