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.

eZ debug

Timing: Jan 15 2025 11:39:34
Script start
Timing: Jan 15 2025 11:39:34
Module start 'layout'
Timing: Jan 15 2025 11:39:34
Module start 'content'
Timing: Jan 15 2025 11:39:35
Module end 'content'
Timing: Jan 15 2025 11:39:35
Script end

Main resources:

Total runtime1.3096 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 599.9453151.2031
Module start 'layout' 0.00600.0031 751.148436.6484
Module start 'content' 0.00911.2995 787.7969860.4609
Module end 'content' 1.30860.0009 1,648.25787.8906
Script end 1.3095  1,656.1484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.2193160.0002
Check MTime0.00120.0919160.0001
Mysql Total
Database connection0.00050.041610.0005
Mysqli_queries1.266196.6772540.0234
Looping result0.00050.0378520.0000
Template Total1.268796.920.6343
Template load0.00190.148420.0010
Template processing1.266796.728220.6334
Template load and register function0.00140.104810.0014
states
state_id_array0.00180.139310.0018
state_identifier_array0.00230.173920.0011
Override
Cache load0.00150.116890.0002
Sytem overhead
Fetch class attribute can translate value0.00080.064220.0004
Fetch class attribute name0.00260.201220.0013
XML
Image XML parsing0.00020.016320.0001
class_abstraction
Instantiating content class attribute0.00000.000620.0000
General
dbfile0.00070.0514100.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs