Adding class to Auto Nav

Permalink
Hello again!
I am searching for solution about my problem:
I am using Auto Nav in my theme (I am converting HTML layout into C5 theme). The navigation has a similar tree:
<ul>
<li></li>
<li></li>
...
<li class=''>
<ul>
<li></li>
<li></li>
</ul>
</li>
</ul>

This is a menu with submenu one level depth. So I want to add styling to <li> element that contains submenu. By default every <li> element in Auto Nav has an empty style.

View Replies:
MoonGrab replied on at Permalink Reply
MoonGrab
Could you please post your menu files? I presume you are trying to edit view.php so please post yours.

If not, then see the code below, it should make sense. It's the default 5.4 autonav template and you might be using an older one if you are struggling with it.

Mind the if ($ni->hasSubmenu) { part.
<?php  defined('C5_EXECUTE') or die(_("Access Denied."));
$navItems = $controller->getNavItems();
/**
 * The $navItems variable is an array of objects, each representing a nav menu item.
 * It is a "flattened" one-dimensional list of all nav items -- it is not hierarchical.
 * However, a nested nav menu can be constructed from this "flat" array by
 * looking at various properties of each item to determine its place in the hierarchy
 * (see below, for example $navItem->level, $navItem->subDepth, $navItem->hasSubmenu, etc.)
 *
 * Items in the array are ordered with the first top-level item first, followed by its sub-items, etc.
 *
 * Each nav item object contains the following information:
 *   $navItem->url        : URL to the page
 *   $navItem->name       : page title (already escaped for html output)
 *   $navItem->target     : link target (e.g. "_self" or "_blank")