PDA


View Full Version : Looping in custom templates


Stember
06-05-2005, 07:43 PM
Hello,

I have a small example code that i wish to show you to see if something is possible in a custom template. I wish to create a module for vBa CMPS and got stuck on one part.

I basicly want me template to do this (Its in PHP):

$number['total'] = 6;
$number[1] = 10;
$number[2] = 20;
$number[3] = 30;
$number[4] = 40;
$number[5] = 50;
$x = 0;
while ($x < $number['total']) {
$x++;
echo $number[$x];
}

So, what i have so far is:

<if condition="$x = 0"> </if>
<if condition="$x = $x + 1"></if>
<if condition="$x<$number[total]">
$number[$x]
<br />
</if>

So any suggestions on the loop i need?

Brian
06-06-2005, 11:48 AM
You can't use loops with if conditions. You would need to create a PHP file and then pass the output to the template.

Stember
06-06-2005, 05:19 PM
But how would i set about doing that? I mean, if i have 100+ dynamic variables, will i need to display it 100+ times in the template? is there an even easier way that i have missed?

Stember
06-06-2005, 08:07 PM
Never Mind. I've found a way:

Loop in the PHP runs a template each time it loops, setting the new variables each time it loops.

Thanks for the help.