Forums / Setup & design / Creating a table with the loop method inside a line.tpl. Which loop variable I should use ?

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.

eZ debug

Timing: Jan 19 2025 07:10:27
Script start
Timing: Jan 19 2025 07:10:27
Module start 'content'
Timing: Jan 19 2025 07:10:28
Module end 'content'
Timing: Jan 19 2025 07:10:28
Script end

Main resources:

Total runtime1.5495 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0112 589.5703180.7656
Module start 'content' 0.01121.3747 770.3359554.4453
Module end 'content' 1.38590.1636 1,324.7813341.9141
Script end 1.5495  1,666.6953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00500.3258210.0002
Check MTime0.00190.1224210.0001
Mysql Total
Database connection0.00130.084510.0013
Mysqli_queries1.427392.11402000.0071
Looping result0.00220.14131980.0000
Template Total1.474095.120.7370
Template load0.00290.185720.0014
Template processing1.471294.941620.7356
Template load and register function0.00010.006410.0001
states
state_id_array0.00480.306710.0048
state_identifier_array0.00310.202320.0016
Override
Cache load0.00240.1566730.0000
Sytem overhead
Fetch class attribute can translate value0.00200.132130.0007
Fetch class attribute name0.00110.070260.0002
XML
Image XML parsing0.00080.053630.0003
class_abstraction
Instantiating content class attribute0.00000.001380.0000
General
dbfile0.02451.5831270.0009
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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