How can I do loops in templates?

Author Message

Adolfo Barragán

Friday 24 January 2003 10:29:43 pm

I've created a calendar and I've separated logic from presentation, so I receive a multidimensional array. Each item is a week wich is again an array with seven items (one for each day). Each day item is an array with two items: the day number and the object id. I want use this object id for a URI like {concat('content/full', $objectId)|ezurl}.

I try a loop in template but print nothing. Furthermore, I don't know create and manipulate variables and loops in "template language" (documentation please).

Now, I resolve using hard code at "myCalendar.php" and sending a string with html tags, but I whish make this on template, so I can change presentation simply modifing CSS, not PHP.

I need translate the following php code to "template language".
Can help me?

$weeks = $Result['weeks'];
print "<table>";
foreach( $weeks as $week )
{
print "<tr>";
for ($i = 0; $i < 7; $i++)
{
$day = $week[$i][0];
$objectId = $week[$i][1];

// the following sentence is mixed php and template code
$dayLink = {concat('content/full/', $objectId)|ezurl)}

if ($objectId == false)
{
print "<td>$day</td>";
} else {
print "<td><a href=\"" . &dayLink ">\"$day</a></td>";
}
}
print "</tr>";
}
print "</table>";

Thanks in advance.
Adolfo Barragán

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 11:32:18
Script start
Timing: Jan 18 2025 11:32:18
Module start 'layout'
Timing: Jan 18 2025 11:32:18
Module start 'content'
Timing: Jan 18 2025 11:32:19
Module end 'content'
Timing: Jan 18 2025 11:32:19
Script end

Main resources:

Total runtime0.7701 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0087 588.0391152.6406
Module start 'layout' 0.00870.0033 740.679739.4766
Module start 'content' 0.01210.7566 780.1563411.6172
Module end 'content' 0.76870.0014 1,191.77348.1406
Script end 0.7701  1,199.9141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4754160.0002
Check MTime0.00150.1914160.0001
Mysql Total
Database connection0.00180.232410.0018
Mysqli_queries0.723293.9095460.0157
Looping result0.00050.0590440.0000
Template Total0.729794.820.3649
Template load0.00220.283320.0011
Template processing0.727594.470720.3638
Template load and register function0.00010.019510.0001
states
state_id_array0.00240.308510.0024
state_identifier_array0.00160.212420.0008
Override
Cache load0.00180.2368320.0001
Sytem overhead
Fetch class attribute can translate value0.00090.112810.0009
Fetch class attribute name0.00120.151410.0012
XML
Image XML parsing0.00010.013910.0001
class_abstraction
Instantiating content class attribute0.00000.001310.0000
General
dbfile0.00070.0943100.0001
String conversion0.00000.001240.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
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/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: 12
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs