show_menu2, version 4.12

 

function show_menu2(
    $aMenu          = 0,
    $aStart         = SM2_ROOT,
    $aMaxLevel      = SM2_CURR+1,
    $aOptions       = SM2_TRIM,
    $aItemOpen      = '[li][a][menu_title]</a>',
    $aItemClose     = '</li>',
    $aMenuOpen      = '[ul]',
    $aMenuClose     = '</ul>',
    $aTopItemOpen   = false,
    $aTopMenuOpen   = false
    )
Ebene 3 Seite 1 &lt;&lt; | Ebene 2 Seite 1 | >> Ebene 3 Seite 3
// get the required information
$info = show_menu2(0, SM2_CURR, SM2_START, SM2_ALL|SM2_BUFFER, 
    '[if(class==menu-current){[level] [sib] [sibCount] [parent]}]', '', '', '');
list($nLevel, $nSib, $nSibCount, $nParent) = explode(' ', $info);

// show previous
$prv = $nSib > 1 ? $nSib - 1 : 0; 
if ($prv > 0) {
    show_menu2(0, SM2_CURR, SM2_START, SM2_ALL, 
        "[if(sib==$prv){[a][menu_title]</a> &lt;&lt;}]", '', '', '');
}
else echo '(no previous)';
echo ' | ';

// show up level
if ($nLevel > 0) {
    $lev = $nLevel - 1; 
    show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB, 
        "[if(level==$lev){[a][menu_title]</a>}]", '', '', '');
}
else echo '(no parent)';
echo ' | ';

// show next
$nxt = $nSib < $nSibCount ? $nSib + 1 : 0; 
if ($nxt > 0) {
    show_menu2(0, SM2_CURR, SM2_START, SM2_ALL, 
        "[if(sib==$nxt){&gt;&gt; [a][menu_title]</a>}]", '', '', '');
}
else echo '(no next)';

full

The full menu

show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_NUMCLASS|SM2_PRETTY, false, false, '<ul class="mark [class]">');

Using CSS selectors to show parents (p), current (c), sibling (s) and children (c-N).

Note: the CSS selectors works only in modern browsers. IE6 is not a modern browser.

sitemap

Creating a full sitemap

show_menu2(SM2_ALLMENU, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_ALLINFO, '[li]<span class="content">[a][page_title]</a> (menu: [a][menu_title]</a>)<br /><i>[description]</i><br />([keywords])</span>', false, '<ul class="sitemap [class]">');

udm4

Using UDM4 popup menus

show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, "\n</li>", false, false, false, '<ul class="udm" id="udm">');

  • Ebene 1 Seite 2
  • Ebene 1 Seite 3
  • Ebene 1 Seite 4
  • Ebene 1 Seite 5
  • Ebene 1 Seite 6
  • Ebene 1 Seite 7
  • Ebene 1 Seite 8
  • Ebene 1 Seite 10
  • default

    The default trimmed menu

    show_menu2();

    breadcrumbs

    Breadcrumbs for the entire current path

    show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB, '<span class="[class]"> > [a][menu_title]</a>', '</span>', '', '', '<b>You are here:</b> <span class="[class]">[a][menu_title]</a>');

    You are here: Ebene 1 Seite 1 > Ebene 2 Seite 1 > Ebene 3 Seite 2

    breadcrumbs2

    Breadcrumbs for a max of 2 levels

    show_menu2(0, SM2_ROOT, SM2_MAX+1, SM2_CRUMB, '<span class="[class]"> > [a][menu_title]</a>', '</span>', '', '', '<b>You are here:</b> <span class="[class]">[a][menu_title]</a>');

    You are here: Ebene 1 Seite 1 > Ebene 2 Seite 1

    ol

    Full Menu using OL

    show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, false, '<ol>', '</ol>');

    1. Ebene 1 Seite 2
    2. Ebene 1 Seite 3
    3. Ebene 1 Seite 4
    4. Ebene 1 Seite 5
    5. Ebene 1 Seite 6
    6. Ebene 1 Seite 7
    7. Ebene 1 Seite 8
    8. Ebene 1 Seite 10

    siblings

    Showing all siblings

    show_menu2(0, SM2_ROOT, SM2_CURR+1, SM2_SIBLING);

    parent

    Getting the menu tree rooted at parent item

    // get the page_id of the root item for the current page
    $nTreeRootId = (int) show_menu2(0, SM2_CURR, SM2_START, SM2_CRUMB|SM2_BUFFER, '[parent]', '', '', '');

    // generate the menu from that root
    echo "Current parent = $nTreeRootId";
    show_menu2(0, $nTreeRootId, SM2_ROOT, SM2_ALL);

    Current parent = 11

    current

    Showing the current tree only

    // generate the menu for the current tree only
    show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_CURRTREE);

    root

    Show the root level only

    show_menu2(0, SM2_ROOT, SM2_START);

    childsib

    Show children and siblings only

    This is often used when splitting menus between the root menu and a side menu showing the children of the current page. This menu will show all of the children of the current top level menu, but will continue to display the siblings of child pages as well when a lower level menu is selected.

    show_menu2(0, SM2_ROOT+1, SM2_CURR+1);

    currlevel

    Current level only

    show_menu2(0, SM2_CURR, SM2_CURR);

    currchild

    Current children only

    show_menu2(0, SM2_CURR+1, SM2_CURR+1);

    first

    First level only

    show_menu2(0, SM2_ROOT, SM2_START);

    second

    Second level only

    show_menu2(0, SM2_ROOT+1, SM2_START);

    trimmed

    Entire tree but trimmed

    show_menu2(0, SM2_ROOT, SM2_ALL, SM2_TRIM);

    specchild

    Children of a specific page (page = Cogs)

    show_menu2(0, 9, SM2_ALL, SM2_ALL); [page_id of Cogs is 9]

    max2

    Maximum of 2 levels

    show_menu2(0, SM2_ROOT, SM2_MAX+1);

    allchild

    All children of the current page

    show_menu2(0, SM2_CURR+1, SM2_ALL);

    hidden

    Children of a hidden menu

    This shows the children of a hidden menu. They don't show up in a normal menu listing and can be used to display a fixed set of menu items. The root of the menu is set to the page ID of the hidden parent.

    show_menu2(0, 19, SM2_ALL, SM2_ALL);

    level2

    All 2nd level menus (not trimmed to current tree)

    show_menu2(0, SM2_ROOT+1, SM2_START, SM2_ALL);

    text

    Menu as text

    show_menu2(0, SM2_ROOT, SM2_START, SM2_ALL, ' | [a][menu_title]</a>', '', '', '', '[a][menu_title]</a>');

    Ebene 1 Seite 1 | Ebene 1 Seite 2 | Ebene 1 Seite 3 | Ebene 1 Seite 4 | Ebene 1 Seite 5 | Ebene 1 Seite 6 | Ebene 1 Seite 7 | Ebene 1 Seite 8 | Ebene 1 Seite 9 | Ebene 1 Seite 10 | SM2 Readme

    multi

    The full menu of menu #2 (multi menu)

    show_menu2(2, SM2_ROOT, SM2_ALL, SM2_ALL);

    sibonly

    Show siblings only and not the current

    show_menu2(0, SM2_CURR, SM2_CURR, '','[if(class!=menu-current){- [a][menu_title]</a><br />}]','','','<br />');

    - Ebene 3 Seite 1
    - Ebene 3 Seite 3
    - Ebene 3 Seite 4
    - Ebene 3 Seite 5


     

    lang

    The sort of menu used for a multi-language menu. The top level is the language, so start from SM2_ROOT+1. Display to the current level plus children. See this page for an example. Note that the "Enterprise" page is considered to be the language code.

    show_menu2(0, SM2_ROOT+1, SM2_CURR+1);

    default2

    Default menu

    Note: this is the default output

    show_menu2();

    notrim

    Use of the extended option: notrim

    Demonstrates the use of the extended option "notrim" with everything else set to default. Compare it to the default output from show_menu2().

    $options = array('flags' => SM2_TRIM, 'notrim' => 1);
    show_menu2(0, SM2_ROOT, SM2_CURR+1, $options);

    orig2

    Output from show_menu for menu #2

    show_menu(2);

    no longer supported (WBCE 1.3.2)

    orig1

    Output from show_menu for menu #1

    show_menu(1);

    no longer supported (WBCE 1.3.2)

    Tests using the show_menu() replacement function

    defaultorig

    Default output from show_menu

    show_menu();

    no longer supported (WBCE 1.3.2)

    •  

    defaultsm2

    Default output from sm2 version of show_menu

    sm2_show_menu();

    no longer supported (WBCE 1.3.2)