recursive template

From: Date: Thu, 20 Mar 2003 15:46:35 +0000
Subject: recursive template
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8777@lists.php.net to get a copy of this message
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. Thanks in advance and Best Regards Eaden McKee

« previous php.smarty.general (#8777) next »