Number of Row for each Item with "fetch"?

Author Message

Peter Schnuerer

Wednesday 29 December 2004 7:49:00 am

Hello!

I'm looping trough the content of a foder:

{set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id, sort_by, $node.sort_array) )}

{section var=child loop=$list_items}
 {node_view_gui view=line content_node=$child}
{/section}

I want an output like this:

+---+-------------------------------------------+
| 1 | my content.....                           |
+---+-------------------------------------------+
| 2 | my content.....                           |
+---+-------------------------------------------+
| 2 | my content.....                           |
+---+-------------------------------------------+

But how do I make the numer of rows ("1", "2", "3",...)

Thanx!
Peter

Tobias Persson

Wednesday 29 December 2004 10:36:50 am

You could do something like:

{set count=0 list_items=fetch_alias( children, hash( parent_node_id, $node.node_id, sort_by, $node.sort_array) )}
<table>
{section var=child loop=$list_items}
{set count=$count|inc}
 <tr><td>{$count}</td><td>{node_view_gui view=line content_node=$child}</td></tr>
{/section}
</table>

Balazs Halasy

Wednesday 29 December 2004 12:07:06 pm

Hi,

Here is a shorter/faster example:

<table>
{section var=Children loop=$list_items}
    <tr><td>
    {$Children.number}
    </td><td>
    {node_view_gui view=line content_node=$Children.item}
    </td></tr>
{/section}
</table>

For more info, look at the doc page for the section function:
http://ez.no/ez_publish/documentation/reference/template_functions/program_flow/section

Balazs

Peter Schnuerer

Sunday 02 January 2005 6:09:32 am

Thank you all!

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 18 2025 14:57:34
Script start
Timing: Jan 18 2025 14:57:34
Module start 'layout'
Timing: Jan 18 2025 14:57:34
Module start 'content'
Timing: Jan 18 2025 14:57:35
Module end 'content'
Timing: Jan 18 2025 14:57:35
Script end

Main resources:

Total runtime0.8877 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 587.9297152.6250
Module start 'layout' 0.00600.0023 740.554739.4453
Module start 'content' 0.00830.8782 780.0000569.8828
Module end 'content' 0.88650.0011 1,349.882812.1406
Script end 0.8877  1,362.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4387160.0002
Check MTime0.00160.1769160.0001
Mysql Total
Database connection0.00080.089810.0008
Mysqli_queries0.829093.3878620.0134
Looping result0.00060.0653600.0000
Template Total0.858796.720.4293
Template load0.00210.236920.0011
Template processing0.856696.492520.4283
Template load and register function0.00010.009810.0001
states
state_id_array0.00050.060410.0005
state_identifier_array0.00070.081220.0004
Override
Cache load0.00190.2096270.0001
Sytem overhead
Fetch class attribute can translate value0.00060.063630.0002
Fetch class attribute name0.00120.138070.0002
XML
Image XML parsing0.00400.452230.0013
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.00330.3742280.0001
String conversion0.00000.001040.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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs