$sql = "select menu_id , menu_name , parent_id from menu " ;
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$res = $dbc->query($sql);
while($row = $res->fetchRow()){
$menu[$row['parent_id']][$row['menu_id']] = $row['menu_name'];
}
function make_menu($parent)
{
global $menu ;
echo '<ul>';
foreach($parent as $menu_id=>$menu_name)
{
echo '<li>'.$menu_name ;
if(isset($menu[$menu_id]))
{
make_menu($menu[$menu_id]) ;
}
echo '</li>';
}
echo '</ul>';
}
$P['menu_bilder_data'] = $menu[0] ;
//menu :off
$smarty->register_function('make_menu' , 'make_menu') ;
ok i have this section of code to retrieve and pass to smarty.
I have registered my make_menu
function as a custom user function with smarty, and in the template i have this code:
{make_menu parent_id=$P.menu_bilder_data}
I'm passing $P
array in index file. It must work but it gives me nothing because it's a recursive function, it returns an array instead of printed nested uls; how can i fix this issue?