Forums / Developer / problem with hash
Damarev .
Thursday 07 February 2008 7:28:30 am
Having a problem setting a hash.
Giving this:
{def $aHash = hash( 'prop1' , 'A string' )}
{set $aHash['two'] = 'Another string'}
or
{set $aHash.two = 'Another string'}
leaves $aHash empty... why?
André R.
Thursday 07 February 2008 7:48:55 am
You can not set a hash like that in templates, you have to create a new hash and use 'merge' to merge them.
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
Thursday 07 February 2008 8:28:05 am
Sorry, I made a mistake.... what I really want is to change the value of an already defined key in the hash, not creating a new one:
{def $aHash = hash( 'property' , 'A string' )}
{set $aHash.property = 'Another string' }
Thursday 07 February 2008 9:02:51 am
The template language in eZ Publish still doesn't support setting properties, so you still need to use merge.The template language in eZ Components on the other hand does ( if I remember correctly ) and it is scheduled to replace the one in eZ Publish hopefully during 2008.
Monday 11 February 2008 4:15:41 am
Thanks André.