Of course, this works when $numberOfCols is an array :)

Werner wrote:
Hi Daniel

Actually that's easy to achieve...

In your php script:

$tpl->numberOfCols = $numberOfCols;

In your TAL template:

<table>
    <tr>
        <tal:block tal:repeat="cell numberOfCols">
            <td tal:content="cell"></td>
        </tal:block>
    </tr>
</table>

Kind Regards,
Werner


Daniel Lima wrote:
Hi,
I'm trying make a table using PHPTAL and this table should be set with dynamic numbers of cols or rows.
To do it in PHP only, i use an increment counter, something like:

$i = 0;
loop {
echo '<td>';
if ($i == $numberOfCols) {
echo "</tr><td>"; //closes a table row and create a new column
$i = 0; //redo the increment counter
}
$i++;
}

So, i am trying to do the same thing using PHPTAL but it dont works fine with increment counters.
My initial code is::
<table>
<tr>
<tal:block repeat="item test" define="i php:0;">
<td tal:content="php: i++">xxx</td>
<tal:block condition="php:(i==numberOfCols)" define="i php:1;">
</tr><td>
</tal:block>
</tal:block>
</table>

Further on PHPTAL dont accept the TR tag as closure.
Somebody can help me?

Regards,

Daniel Lima
Web Developer
Cilens Software
http://www.cilens.info/
Marie von Ebner-Eschenbach <http://www.brainyquote.com/quotes/authors/m/marie_von_ebnereschenbac.html> - "Even a stopped clock is right twice a day."
------------------------------------------------------------------------

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

------------------------------------------------------------------------

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to