autonav - PHP code to create a new CSS id for each level of menu/unordered list

Permalink 1 user found helpful
I am trying to create some PHP code which will create a new CSS class for each level of menu lists, specifically:

Parent (id: side-nav)
- Child 1 (id:side-nav-1)
-- Child 2 (id:side-nav-2)
--- Child 3 (id:side-nav-3)
---- etc
----- etc

The intent is to allow me to create specific CSS for each ID resulting in a custom autonav block. Unfortunately, my knowledge of PHP is rather limited to accomplish.

Here is the CSS code I have been working with in my block and would like to modify:
$target = $ni->getTarget();
         if ($target != '') {
            $target = 'target="' . $target . '"';
         }
         if (!$containsPages) {
            echo("<ul id=\"side-nav\">");
         }
         $containsPages = true;
         $thisLevel = $ni->getLevel();
         if ($thisLevel > $lastLevel) {
            echo("<ul>");
         } else if ($thisLevel < $lastLevel) {
            for ($j = $thisLevel; $j < $lastLevel; $j++) {
               if ($lastLevel - $j > 1) {
                  echo("</li></ul>");


Any and all suggestions are appreciated

 
Arraay replied on at Permalink Reply
Hey wgamborski
Sorry for stealing your topic, but i am also looking for such a solution.
Did you figure it out yourself, or is there anyone else out there, who's an expert for these sort of things?

Any help would be appreciated.
Thanks
wgamborski replied on at Permalink Reply
Arraay,
Thanks for note. Unfortunately, no luck with this request. What I ended up doing to modifying lists and structure to accommodate.

Good luck
mkly replied on at Permalink Reply
mkly
You might want to check out @jordanlevs new autonav template
https://github.com/jordanlev/c5_clean_block_templates/blob/master/au...

I highlighted that info in question. You can scroll down to the bottom and see where you can add stuff it's pretty well explained but basically you need to add
if($ni->level) {
  $classes[] = 'level-'.$ni->level;
}

after line 157 and before 210

Happy Hacking,
Mike
wgamborski replied on at Permalink Reply
mkly,
Thanks, just getting back to updating the theme I created (though it has been many months)

Now a total newb question, where do I place the view.php file, and how do I call it? It is about where I place the file - within the autonav-templates folder or just within the autonav folder?

Thanks in advance.
wgamborski replied on at Permalink Reply
Bump
adajad replied on at Permalink Reply
adajad
webroot/blocks/autonav/templates/[name_of_your_template]/view.php

read more about templates and overrides here:

http://www.concrete5.org/documentation/how-tos/designers/change-how...
http://www.concrete5.org/documentation/how-tos/developers/change-th...