Question

when my primary menu is like item menu1/submenu1.2, de li gets the class active, so i can style it, for example in a different color.

however, if i go to page menu1/submenu1.2/153 then the active class is missing.

Or anything like menu1/submenu1.2/* is the active class missing.

How can I solve this?

Was it helpful?

Solution

In your example of menu1/submenu1.2/153 the active class should have moved to 153. You can still style submenu1.2 differently by looking for the active-trail class on the <li>

For example, if you go to admin/content/comment the menu's html should look similar like this:

<ul class="menu">
  <li class="expanded active-trail">
    <a href="/drupalsite/?q=admin">Administer</a>
    <ul class="menu">
      <li class="expanded first active-trail">
        <a title="Manage your site's content." href="/drupalsite/?q=admin/content">Content management</a>
        <ul class="menu">
          <li class="leaf first active-trail">
            <a class="active" title="List and edit site comments and the comment moderation queue." href="/drupalsite/?q=admin/content/comment">Comments</a> 
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

That means you can style the admin and content links by using CSS something like the following:

li.active-trail a {
    /*Whatever style here*/
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top