[SMARTY] Creating custom loop block function

Kaloyan Tsvetkov <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
I need some help from someone who's got more experience than me with
Smarty. I've been tasked to create a set of block functions for
rendering tables. Here's what the syntax look like:

---proba.html---

       {list data=$rows}

               {head}
                       {column}1{/column}
                       {column}2{/column}
                       {column}3{/column}
               {/head}

               {rows}
                       {cell}
                               0. {$SKU} {$data.SKU}
                       {/cell}
                       {cell} 0. {$brand} {$data.brand} {/cell}
                       {cell} 0. {$model} {$data.model} {/cell}
               {/rows}
       {/list}

---end-of-file---

The $rows data is somethink like that:

---proba.php---
.....

$smarty->assign('rows',
       array(
               array(
                       SKU => 1,
                       brand => 11,
                       model => 11,
                        ),

               array(
                       SKU => 2,
                       brand => 22,
                       model => 22,
                       ),
               )
       );

....
---end-of-file---

I need to make the smarty_block_rows() block function loop over the
data in $rows. In the same time I need to access the elements (SKU,
brand, model) on each loop. The HTML for the block components are read
from an external file. If you want to take a look at the code, please
follow this link: http://kaloyan.info/loop.zip.

Thanks in advance to all which will provide any help, comment or
advice.

K.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.