Simplistic Layout
Here's a very simplistic menu which you can either use as your main navigational menu or as a simple secondary navigation menu. I've placed it in a Snippet for convenience and include that Snippet in my site's Layout.
In short what it does:
- Display a title
- If the currently chosen page has subpages, do..
- Display each subpage
- In all cases except when it's the Homepage, display a back link to the higher level menu
and here's the code:
<h1><?php echo $this->title; ?> menu</h1>
<ul class="sidemenu">
<?php
if (count($this->children()) > 0) {
foreach($this->children() as $menu):
echo '<li>'.$menu->link($menu->title, (in_array($menu->slug, explode('/', $this->url)) ? ' class="current"': null)).'</li>';
endforeach;
}
echo url_match('/') ? '': '<li>'.$this->parent->link('back', (in_array($this->slug, explode('/', $this->url)) ? ' class="current"': null)).'</li>';
?>
</ul>