Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function: multi-level navigation. / Plugin for version 2!
#19
menu_data function already sorts the returned XML data on menuOrder so there is no need to sort it again,
just change the top 2 lines and replace with

Code:
function menu_master() {
        $data = simplexml_load_string(menu_data('',true));
        $menu = $data->xpath('//*[menuStatus="Y"][parent=""]');
        if (count($menu)>0) {
            echo '<ul class="menu">';
            foreach ($menu as $link) {
                if ("$link->slug"=="") $link->slug = "index";
                $prnt = count($data->xpath('//item[slug="'.return_page_slug().'"][parent="'.$link->slug.'/"]'));
                echo '<li'.("$link->slug"==return_page_slug()?' class="active"':($prnt>0?' class="parent"':'')).'><a href="'.$link->url.'">'.($link->menu!=""?$link->menu:$link->title).'</a>';
                $menu = $data->xpath('//*[parent="'.$link->slug.'/"]');
                if (count($menu)>0) {
                    echo '<ul class="submenu">';
                    foreach ($menu as $link) {
                        echo '<li'.("$link->slug"==return_page_slug()?' class="active"':'').'><a href="'.$link->url.'">'.($link->menu!=""?$link->menu:$link->title).'</a></li>';
                    }
                    echo '</ul>';
                }
                echo '</li>';
            }
            echo '</ul>';
        }
    }

EDIT: ************ IGNORE BELOW THIS, I'm talking rubbish....

Not sure about the second submenu query? Why are you checking for menuStatus=Y for the submenu, will this not be off ??

They way I do it is,

o - create all the top level pages and set the menu order as normal.
o - for each page as a submenu, just create the page and set the parent to be to top level menu.

Also function won't work for us poor unfortunates who cant use prettyUrls.... Smile

Mike
My Github Repos: Github
Website: DigiMute
Reply


Messages In This Thread
Function: multi-level navigation. / Plugin for version 2! - by n00dles101 - 2009-11-19, 02:46:44



Users browsing this thread: 1 Guest(s)