0

I have taken the standard code for secondary menu from a Drupal 7 theme:

 <?php if ($secondary_menu): ?>
            <?php print $search_form; ?>
          <?php endif; ?>
    <?php if ($search_form): ?>
        <?php print theme('links__system_secondary_menu', array(
          'links' => $secondary_menu,
          'attributes' => array(
            'id' => 'secondary-menu-links',
            'class' => array('menu', 'nav', 'navbar-nav'),
              ),
              'heading' => array(
                'text' => t('secondary'),
                'level' => 'h2',
                'class' => array('element-invisible'),
                  ),
                    )); ?>
                  <?php endif; ?>

Now the ht,l output generates some autogen css witch i whant to get rit of and replace with my own classes?

<h2 class="element-invisible">secondary</h2>

<ul id="secondary-menu-links" class="menu nav navbar-nav">
<li class="menu-3 first"><a href="/user">My account</a></li>
<li class="menu-15 last"><a href="/user/logout">Log out</a></li>
</ul>                                  
</div>

How to delete menu-3 and menu-15 as well as all classes following when we add more links and add some custom links to work with stuff like font awesome?

1 Answer 1

0

You can use this preprocess hook to modify the menu classes.

For example, modify the output of the secondary menu links like this.

function YOURTHEME_links__system_secondary_menu(&$variables)
{
   $output = "";

   foreach ($variables['links'] as $item => $link) {
      $classes = array('class1', 'class2');
      $output .= sprintf('<li class="%s">%s</li>', implode(' ', $classes), l($link['title'], $link['href']));
   }

   return $output;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.