Hello,
I found a lot of great examples of recursive navigation in the forums and have based my example here off of those. I'm having trouble adding an active class to the menu. Ultimately, I'd like to add the active class to the active parent and child item, but I've started with just trying to get the parent to have an active class. Although the menu renders as desired, I must be missing something here with adding the class:
<?php
function listChildrenTree($children) {
echo "<ul class='span-24'>";
foreach($children as $child) {
if($child === $page) $class = " current"; else $class= ' ';
echo "<li class=' $class'><a href='{$child->url}'>{$child->title}</a> ";
if($child->numChildren && $child->template != 'page-article') listChildrenTree($child->children);
echo "</li>";
}
echo "</ul>";
}
listChildrenTree($pages->get('/')->children);
?>
Thanks for any suggestions you may be able to provide.