Creating a table with the loop method inside a line.tpl. Which loop variable I should use ?

Author Message

laurent le cadet

Wednesday 15 October 2003 8:19:58 am

Hi,

Here's my template to print content as line.

{default node_name=$node.name}
<a href={concat('content/view/full/',$node.node_id)|ezurl}>{$node_name|wash}</a>

---> This show if it's a 1 or 2 stars hotel

{section show=$node.data_map.uneetoile.data_int}<img src="/pictos/1_etoile.gif" align="left">{/section}
{section show=$node.data_map.deuxetoiles.data_int}<img src="/pictos/1_etoile.gif" align="left"><img src="/pictos/1_etoile.gif" align="left">{/section}

<---

{/default}

I want to organize items in a table but I don't know which loop variable I must use :

{section name=Child loop=$......}

...and if I must create a "let".

I'm clear enough ?

Laurent

Tore Skobba

Wednesday 15 October 2003 8:41:17 am

First of all, this "Creating a table with the loop method inside a line.tpl. " I do not understand? line.tpl is typically used within an loop, for example: an news folder which contains several articles renders by displaying the "line.tpl" for all articles within the news folder.

Organize how?? Do you mean to sort and have all 1 star hotels togther, then 2 star hotels again? If yes, then a simple solution could be.

1: Name all 1 star hotels "1 star: hotelname1","1 star:hotelname2" etc. Then do the same with 2,3.. i.e. "2 star: hotelname" ..
2: Edit the folder that contains the hoteldata, and select "sort by" "name". Then in your fetch use "sort_by,$node.sort_array".

See short example below:

{let children=fetch('content',list,hash(parent_node_id,$node.node_id,sort_by,$node.sort_array))}

{section name=Child loop=$children}
<p>{attribute_view_gui attribute=$Child:item.data_map.uneetoile.data_int}</p>
{/section}
{/let}

This is a quick and dirty solutions and there are more solutions. Another one might be to put the number of stars variable in the "name" attribute of the hotel content classes, then you do not need to cluster the hotel names with the number of stars.

Cheers

laurent le cadet

Wednesday 15 October 2003 9:30:19 am

Hi Tore,

Ok. Line.tpl is not made for looping.
So I have to make my loop in my folder.tpl :

{section show=$with_children}
{section name=Child loop=fetch(content, tree, hash(
parent_node_id, $node.node_id,
offset, $view_parameters.offset,
sort_by, $node.sort_array,
class_filter_type, exclude,
class_filter_array, array( 1, 10 )) )}
{node_view_gui view=line content_node=$Child:item}<br>
{/section}
{/section}

What I want to print is all the item with some of there attribute (ex: {attribute_view_gui attribute=$content_version.data_map.adresse}
I can do it directly in my override/template/line_folder.tpl, it works fine) but in a table with a row per attribute.

Tore Skobba

Wednesday 15 October 2003 11:07:33 am

Hi Laurent

Not at work so I do not have acces to my stuff :(. So can't give you any specific tips. But I do think you should check out the tutorial at sitepoint (http://www.sitepoint.com/article/1208). It has a step by step guide on how to display the content of an folder with the use of "line.tpl" called from an folder template.

First of all you must save the results from your fetch in an variable, this is typically done with let. i.e

{let children=fetch('content','list',hash(parent_node_id,$node.node_id,sort_by,$node.sort_array,offset,$view_parameters.offset))}

{/let}

laurent le cadet

Thursday 16 October 2003 1:45:30 am

Hi Tore,

Here's my line_hotel.tpl.

{default node_name=$node.name}
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href={concat('content/view/full/',$node.node_id)|ezurl}>{$node_name|wash}</a></td>
<td>{section show=$node.data_map.uneetoile.data_int} <img src="/pictos/1_etoile.gif" align="left">{/section}{section
show=$node.data_map.deuxetoiles.data_int} <img src="/pictos/1_etoile.gif" align="left"><img src="/pictos/1_etoile.gif" align="left">{/section}{section
show=$node.data_map.troisetoiles.data_int} <img src="/pictos/1_etoile.gif" align="left"><img src="/pictos/1_etoile.gif" align="left"><img src="/pictos/1_etoile.gif" align="left">{/section}{section
show=$node.data_map.quatreetoiles.data_int} <img src="/pictos/1_etoile.gif" align="left"><img src="/pictos/1_etoile.gif" align="left"><img src="/pictos/1_etoile.gif" align="left"><img src="/pictos/1_etoile.gif" align="left">{/section}<br></td>
<td>{attribute_view_gui attribute=$content_version.data_map.commune}</td>
</tr>
</table>
{/default}

It don't work as I want cause it create a table for each object which as been sort.
Do you think it's possible to do that in one table with a row per object with some attributes in cells ?

Laurent.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.