Building an array inside a loop

Author Message

Anja Lundin

Wednesday 09 February 2005 1:54:08 am

Hi,
I would like to know if the is a way of buildning an array inside a loop. I would like the remaining items (see the code below) to be items in a new array. After that I want to count the items in the new array. Is it possible?

This is the loop, so far:

{section name=Child loop=fetch('content','list', hash(parent_node_id, $node.node_id))}			
{section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('kopes')}
{section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('skankes')}
{section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('bytes')}
								
{*Here is where I'd like to build an array with the items that are not excluded*}
	
{/section}

{*Here is where I'd like to count the items in the new array*}	

Thanks in advance!
/Anja

------------------------------------
Anja Lundin
Developer, Novitell AB
Sweden

www.novitell.se

Tom Couwberghs

Wednesday 09 February 2005 2:02:07 am

Try something like:

{let filtered_items=array()}
   {section name=Child loop=fetch('content','list', hash(parent_node_id, $node.node_id))}
   {section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('kopes')}
   {section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('skankes')}
   {section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('bytes')}

    {set filtered_items=$filtered_items|append($Child:item)}
   {/section}

    {$filtered_items|attribute(show)}
{/let}

Anja Lundin

Wednesday 09 February 2005 2:13:25 am

Thanks Tom!
The attribute(show), doesnt show anything. I guess it means the array is empty? I'll try to search on the webbpage and see if I find something more on arrays.

------------------------------------
Anja Lundin
Developer, Novitell AB
Sweden

www.novitell.se

Tom Couwberghs

Wednesday 09 February 2005 3:36:53 am

OK i've found the problem. This trick doesn't work with section name. Try it like this:

{let filtered_items=array()}
{section var=Child loop=fetch('content','list', hash(parent_node_id, $node.node_id))}
    ...
   {set filtered_items=$filtered_items|append($Child.item)} 
{/section}
{/let}

Now the set and let are in the same scope, so that should work.

Anja Lundin

Wednesday 09 February 2005 4:32:05 am

It works now!
Thanks a lot, Tom!
/Anja

------------------------------------
Anja Lundin
Developer, Novitell AB
Sweden

www.novitell.se

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 20 2025 01:00:04
Script start
Timing: Jan 20 2025 01:00:04
Module start 'layout'
Timing: Jan 20 2025 01:00:04
Module start 'content'
Timing: Jan 20 2025 01:00:04
Module end 'content'
Timing: Jan 20 2025 01:00:04
Script end

Main resources:

Total runtime0.8022 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 589.1563152.6250
Module start 'layout' 0.00730.0031 741.781339.4453
Module start 'content' 0.01050.7905 781.2266566.0078
Module end 'content' 0.80100.0011 1,347.234416.1641
Script end 0.8021  1,363.3984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3937160.0002
Check MTime0.00130.1627160.0001
Mysql Total
Database connection0.00090.115710.0009
Mysqli_queries0.737191.8840630.0117
Looping result0.00070.0906610.0000
Template Total0.764095.220.3820
Template load0.00200.255120.0010
Template processing0.762094.985820.3810
Template load and register function0.00020.026310.0002
states
state_id_array0.00130.163210.0013
state_identifier_array0.00160.195420.0008
Override
Cache load0.00180.2195280.0001
Sytem overhead
Fetch class attribute can translate value0.00070.081920.0003
Fetch class attribute name0.00130.162770.0002
XML
Image XML parsing0.00460.569220.0023
class_abstraction
Instantiating content class attribute0.00000.0028100.0000
General
dbfile0.00430.5391220.0002
String conversion0.00000.001340.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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/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: 26
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs