Recursive menu, menu of menus

From: Date: Fri, 26 Sep 2003 12:56:27 +0000
Subject: Recursive menu, menu of menus
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10274@lists.php.net to get a copy of this message
Hi, I'm doing a recursive menu, that is a menu containing children menus. It has about 4-5 levels, but I don't want to limit the number of levels. I've done it in the following way index.tpl: {include file="menu.tpl" menu_items=$page->menu} menu.tpl <div style="clear:both;padding-left:10px;"> {foreach from=$menu_items item=menu_item} {$menu_item.name}<br /> {if $menu_item.has_subs} {include file="menu.tpl" menu_items=$menu_item.sub_menus} {/if} {/foreach} </div> This is just for testing as it will be more complex later on, but do any of you know of a faster way of doing this and does smarty have to read the menu.tpl every time is has to open a sub menu (that's a lot of times). Also this could be help for somebody trying to build a similar thing, but don't know anyway of doing it. Martin Kjeldsen

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