Re: [SMARTY] recursive template
| From: | Juzan Jean-Michel | Date: | Thu, 20 Mar 2003 15:53:44 +0000 |
| Subject: | Re: [SMARTY] recursive template | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8778@lists.php.net to get a copy of this message | ||
Le jeu 20/03/2003 à 16:46, Eaden McKee a écrit :
> Hi there,
> I love smarty, it makes things real easy :)
>
> I have one question on how to something with smarty that I can do with php.
>
> Say I have a recursive array :
> [0] -> name = item 1
> [0] -> id = 1
> [0] -> childern = null
> [1] -> name = item 2
> [1] -> id=2
> [1] -> children = array (
> [0] -> name = child of item 2
> [0] -> id = 4
> [0] -> children = null
>
> )
>
> Etc. I hope you get the idea. The php function would look like
>
> function printarray($array) {
> echo "<ul>";
> foreach($array as $item) {
> echo "<li>";
> echo $item->name;
> if ( $item->children ) {
> printarray($item->children);
> }
> echo "</ul>";
>
> }
> }
>
> How would I do this with smarty? I would like to do it with 3 smarty
> tags with one as the begining, one where the children go, and one for
> the end, and I don't want to recursivly include templates.
I hope this help:
http://smarty.php.net/manual/en/language.function.section.php
Example 7-18. nested sections
--
Jean-Michel Juzan jmjuzan@ecreasol.ch
Direction Informations & Technologies
eCreaSol - NetWork Creative Solutions SARL - http://www.ecreasol.ch/
PGP public keys server : http://www.keyserver.net
Attachment: [application/pgp-signature] signature.asc
Attachment: [application/pgp-signature] signature.asc