Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am working on Drupal 7 project (omega 4 subtheme) with panels and views. I need to assign ID an ID (id="nav") to a DIV that wraps main menu UL. It is a child of div.l-region--navigation. It's the second row of the example bellow.

<div class="l-region l-region--navigation">
<div class="panel-pane pane-block pane-system-main-menu">
    <ul class="menu">
        <li><a href="home">Home</a></li>
        <li><a href="home">Home</a></li>
    </ul>    
</div>

Anyone knows how to do this? Is there a specific drupal way of doing this?

share|improve this question

2 Answers 2

function mytheme_links__system_main_menu($variables) {
$site_frontpage = variable_get('site_frontpage', 'node');
  $html = "<nav id='main-nav' class='animate'>\n";
  foreach ($variables['links'] as $link) {
      if($link['href'] == '<front>') {
        $html .= "<a class='1' href='" .$site_frontpage ."'>" .$link['title'] ."</a>";
      }
      else {
        $html .= "<a class='2' href='" .$link['href'] ."'>" .$link['title'] ."</a>";
      }
  }
  $html .= "</nav>\n";

  return $html;
}

The code can be used in template.php to override the output of the . However, the only variable it seems to accept is $tree, which prints out all the contents of a and so is not very helpful.

share|improve this answer
    
I agree - not very helpful indeed. –  Zel Jul 21 at 16:20

You can simply achieve that using the Menu attributes module

This simple module allows you to specify some additional attributes for menu items such as id, name, class, style, and rel.

share|improve this answer
    
This sounds pretty much what I need. BTW, do you know can I target the wrapping DIV or only Menu Items such as <li>? –  Zel Jul 21 at 13:39
    
@ Krishna Mohan, I checked the module and it allows additional attributes only on link items (a:). That's nice but not what I need. –  Zel Jul 21 at 16:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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