Auto Nav second level pages

Permalink 1 user found helpful
Is it possible to change the css class of a second level page as it appears in an Auto Nav menu? Does every single link in an Auto Nav menu have to be the same class?

Thank you in advance for any help.

 
jordanlev replied on at Permalink Reply
jordanlev
You can do this by creating a custom template for the autonav menu. Create a new directory in your site at:
YOURSITE/blocks/autonav/
Then copy this file into that new directory you created:
YOURSITE/concrete/blocks/autonav/view.php

Now edit that new file (the one in YOURSITE/blocks/autonav/view.php -- NOT in the "concrete" directory) and find this chunk of code:
if ($c->getCollectionID() == $_c->getCollectionID()) { 
   echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
} elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) ) { 
   echo('<li class="nav-path-selected"><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</a>');
} else {
   echo('<li><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() . '</a>');
}

and change it to something like this:
if ($thisLevel == 1) {
   $secondLevelClass = 'some-class';
} else {
   $secondLevelClass = '';
}
if ($c->getCollectionID() == $_c->getCollectionID()) { 
   echo('<li class="nav-selected nav-path-selected ' . $secondLevelClass . '"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
} elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) ) { 
   echo('<li class="nav-path-selected ' . $secondLevelClass . '"><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</a>');
} else {
   echo('<li class="' . $secondLevelClass . '"><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() . '</a>');
}


Haven't tested this out but I think it should work.

Good luck!

-Jordan
bek replied on at Permalink Reply
I know this discussion is > 1 yr old, but the solution offered by jordanlev is THE BEST. Thanks v. much, really helped me out :)
jordanlev replied on at Permalink Reply
jordanlev
Thanks! I've since written a robust tutorial on how to use an even better autonav template, in case you're interested:
http://c5blog.jordanlev.com/blog/2011/12/customizing-the-autonav-te...