Hi,

This is one of the cases where TAL is a bit strange to work with. The
following should work even if the HTML generated is not standards compliant.

<tal:block repeat="image images">
  <tal:block tal:replace="structure '&lt;tr&gt;'"
tal:condition="php:repeat.image.index % 5 == 0" />
  <td>
    <img src="${image/src}" />
  </td>
</tal:block>

Another option (better in my opinion) would be to split the list in chunks:

<tr tal:repeat="chunk php:array_chunk(images, 5)">
  <td tal:repeat="image chunk">
    <img src="${image/src}" />
  </td>
</tr>

ciao,
/imv


On Sat, Nov 22, 2008 at 3:24 PM, Tanax <[EMAIL PROTECTED]> wrote:

> Hi!
>
> I'm wondering how to solve this, cause I have no idea.
>
> I'm having the php pull an array of images from the DB. Then I'm iterating
> through them with PHPTAL and writing them out in a table.
> Problem is this:
>
> <table tal:condition="showImages" cellspacing="5px">
>
>             <tbody>
>
>                 <tr>
>                     <td tal:repeat="image images">
>                         <a href="view.php?image=${image/image_id}"><img
> src="${path}/${image/image_name}" border="0" /></a>
>                     </td>
>                 </tr>
>
>             </tbody>
>
> </table>
>
> As you see, if there are 50 images in DB, it will echo out 50 images on 1
> row. If I instead place the repeat in the tr tag, it will echo out 1 image /
> row, on 50 rows. How could I make it write out a </tr><tr> after say.. 6
> images? So I get 6 images per row?? Is this even possible? Cause I have no
> idea how to solve this.
>
> Thanks in advance!
> Marcus
>
> --
> Tanax
>
> _______________________________________________
> 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