2010-04-09, 00:32:13
Hello ...
A little hack to genrate submenu of the current page
put this code in your template ...
A little hack to genrate submenu of the current page
put this code in your template ...
Code:
<?php
$sm = '';
$sm1 = '';
$data=simplexml_load_string(menu_data('',true));
$topmenu= subval_sort($data->xpath("//*[menuStatus='Y']"),'menuOrder');
foreach ($topmenu as $menu){
// output the top level menu items
//$sm .= "<li>".$menu->slug."</li>";
$submenus= $data->xpath("//*[parent='".$menu->slug."']");
// output submenu if it exists
if (count($submenus) != 0) {
$sm1 = '';
$sm1 .= "<ul class='submenu'>";
if ( trim(return_page_slug()) == trim($menu->slug)) { $sm1ok = 1; } else { $sm1ok = 0; }
foreach ($submenus as $submenu){
if ( trim(return_page_slug()) == trim($submenu->slug)) { $sm1ok = 1; }
$sm1 .= '<li><a href="'.$menu->slug.'/'.$submenu->slug.'">'.$submenu->slug."</a></li>";
}
$sm1 .= "</ul>";
if ($sm1ok == 1) {
$sm .= $sm1;
}
}
}
echo $sm;
?>