Light-weight, fast, simple and powerful!
Translations of this page?:

Recipe: "Rolling" navigation in sidebar

This system works to any depth of levels you choose to use, but it only gives the navigation from the current page. It is “navigation lite”; it will always point from the current page “up” to its parent (if there is one), and always point “down” from the current page to its children (if there are any). It offers a nice secondary navigation system, complementing the main top-level navigation that Wolf gives by default. The menu looks something like this:



Use this code in your site’s layout: it will not work as an “inherited” snippet. You can either put this code in the layout itself, or make a snippet for it, but call the snippet, e.g.,

<?php $this->includeSnippet('extra_nav') ?>

in the layout. Include it inside the sidebar DIV, probably best at the top, but you can put it anywhere you like:

<?php if ($this->level() != 0) { echo $this->parent->link($this->parent->title()).'<br />&#8593;<br />'; } ?>
<?php echo $this->title(); ?>
    if (count($this->children()) > 0 && $this->title() != 'Articles') {
      echo '<br />';
      foreach($this->children() as $subMenu):
        echo '&#8627;&nbsp;'.$subMenu->link($subMenu->title, (in_array($subMenu->slug, explode('/', $this->url)) ? ' class="current"': null)).'<br />';
    echo (count($this->children()) > 0 && $this->slug() == 'articles') ? '<br />&#8595;' : '';

This menu system:

  1. checks to see whether you are “Home”, in which case the “upward” navigation is omitted;
  2. checks to see whether it is your “Articles” page,1) and if it is, points only to the Monthly Archives which are (by default) beneath it;
  3. prints the current page title (unlinked, of course);
  4. lists all the subpages to the current page with links.

You can always change the arrows/layout, etc., as you please. Note that this approach does not use a <ul>, but just a series of <br />’s.

1) If you have changed the name of your Articles page to “News” (or whatever), you will need to change the all the occurrences of “A/articles” in the subnav code to the new name (e.g. N/news).
navbook/rolling-vertical.txt · Last modified: 2011-09-12 00:46 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 / design by yello studio / Wolf CMS Inside