How can I accomplish this kind of navigation:
<ul>
<li><a href="#">Top Menu Item 1</a>
<ul>
<li><a href="#">Submenu Item 1</a></li>
<li><a href="#">Submenu Item 2</a></li>
<li><a href="#">Submenu Item 3</a></li>
</ul>
</li>
<li><a href="#">Top Menu Item 2</a>
<ul>
<li><a href="#">Submenu Item 1</a>
<ul>
<li><a href="#">Sub Submenu Item 1</a></li>
<li><a href="#">Sub Submenu Item 2</a></li>
<li><a href="#">Sub Submenu Item 3</a></li>
</ul>
</li>
<li><a href="#">Submenu Item 2</a></li>
</ul>
</li>
<li><a href="#">Top Menu Item 3</a></li>
</ul>
News page must not list it's children (news entries).
Selected page in the tree must have an "selected" class appended to it.
I've used to do it this way in WolfCMS:
<ul>
<li><a<?php echo url_match('/') ? ' class="selected"': ''; ?> href="<?php echo URL_PUBLIC; ?>">Home page</a></li>
<?php foreach($this->find('/')->children() as $menu): ?>
<?php if($menu->slug() == 'news') : ?>
<li><?php echo $menu->link($menu->title, (in_array($menu->slug, explode('/', $this->url)) ? ' class="selected"': null)); ?></li>
<?php endif; ?>
<li><?php echo $menu->link($menu->title, (in_array($menu->slug, explode('/', $this->url)) ? ' class="selected"': null)); ?>
<ul>
<?php foreach($menu->children() as $child):?>
<?php if($child->slug() == 'news') : ?>
<li><?php echo $child->link() ?></li>
<?php endif; ?>
<?php if($child->childrenCount() > 0 && $child->slug() != 'news') : ?>
<li><?php echo $child->link($child->title, (in_array($child->slug, explode('/', $this->url)) ? ' class="selected"': null)); ?>
<ul>
<?php foreach ($child->children() as $grandchild) : ?>
<li><?php echo $grandchild->link($grandchild->title, (in_array($grandchild->slug, explode('/', $this->url)) ? ' class="selected"': null)); ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php if($child->childrenCount() == 0) : ?>
<li><?php echo $child->link() ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</li>
<?php endforeach; ?>
</ul>
Thanks