Forums / General / Number of Row for each Item with "fetch"?

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!