Forums / Install & configuration / How can I do loops in templates?

How can I do loops in templates?

Author Message

Adolfo Barragán

Friday 24 January 2003 10:24:06 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).

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