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.

eZ debug

Timing: Jan 19 2025 01:01:56
Script start
Timing: Jan 19 2025 01:01:56
Module start 'layout'
Timing: Jan 19 2025 01:01:56
Module start 'content'
Timing: Jan 19 2025 01:01:57
Module end 'content'
Timing: Jan 19 2025 01:01:57
Script end

Main resources:

Total runtime0.6344 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.0047 590.7813152.6875
Module start 'layout' 0.00470.0026 743.468839.6172
Module start 'content' 0.00730.6258 783.0859549.2891
Module end 'content' 0.63310.0012 1,332.375016.6406
Script end 0.6343  1,349.0156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5113160.0002
Check MTime0.00130.2077160.0001
Mysql Total
Database connection0.00050.077610.0005
Mysqli_queries0.567789.4989630.0090
Looping result0.00070.1164610.0000
Template Total0.609496.120.3047
Template load0.00170.270420.0009
Template processing0.607695.786620.3038
Template load and register function0.00010.016710.0001
states
state_id_array0.00090.135810.0009
state_identifier_array0.00080.123920.0004
Override
Cache load0.00160.2492730.0000
Sytem overhead
Fetch class attribute can translate value0.00060.099920.0003
Fetch class attribute name0.00150.230760.0002
XML
Image XML parsing0.00050.085520.0003
class_abstraction
Instantiating content class attribute0.00000.003280.0000
General
dbfile0.00070.1128160.0000
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
3content/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
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
9content/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: 33
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs