Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function: multi-level navigation. / Plugin for version 2!
#41
Zeg,

I found that I needed your menu structure and it appears to work well.
However, I wanted to look better in my source code instead of it being bunched up all together.

Here is my change that causes the menu structure to be tabbed and easy to read.
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">'."\r";
        foreach ($menu as $link) {
            if ("$link->slug"=="") $link->slug = "index";
            $prnt = count($data->xpath('//item[slug="'.return_page_slug().'"][parent="'.$link->slug.'/"]'));
            $menu = $data->xpath('//*[menuStatus="Y"][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>'.(count($menu)>0?"\r":'');
            if (count($menu)>0) {
                echo "\t".'<ul class="submenu">'."\r";
                foreach ($menu as $link) {
                    echo "\t".'<li'.("$link->slug"==return_page_slug()?' class="active"':'').'><a href="'.$link->url.'">'.($link->menu!=""?$link->menu:$link->title).'</a></li>'."\r";
                }
                echo "\t".'</ul>'."\r";
            }
            echo '</li>'."\r";
        }
        echo '</ul>'."\r";
    }
}
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply


Messages In This Thread
Function: multi-level navigation. / Plugin for version 2! - by internet54 - 2010-01-10, 09:37:43



Users browsing this thread: 1 Guest(s)