Drupal 7 Main Menu

I desperately need help. I am trying to customize the main menu (only) in Drupal 7 to fit my blueprintcss needs. I tried to find the answer in the documentation, but there is no simple example for this, which makes it a little more complicated.

The basic requirement is that other menus (navigation, etc.) do not affect the style of the main menu.

My page.tpl.php includes this code:

<?php if ($main_menu): ?>
<div class="span-9" id="topmenu">
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu',
'class' => array('links', 'inline', 'clearfix'),
),
)); ?>
</div>
<?php endif; ?>

The output shows:

<div class="span-9" id="topmenu"> 
<ul id="main-menu" class="links inline clearfix">
 <li class="menu-151 first"><a href="/drupal/" title="">Home</a></li> 
 <li class="menu-152"><a href="/drupal/" title="">Contact Us</a></li> 
 <li class="menu-153 last"><a href="/drupal/" title="">About Us</a></li> 
</ul>
</div>

While the desired result should be something like this:

<div class="span-9" id="topmenu">
 <div class="span-3 menu-151"><a href="/drupal/" title="">Home</a></div>
 <div class="span-3 menu-152"><a href="/drupal/" title="">Contact Us</a></div>
 <div class="span-3 menu-153 last"><a href="/drupal/" title="">About Us</a></div>
</div>
+3
source share
1 answer

You can override the theme function to modify the generated markup.

To achieve this:

  • Find the theme function you are calling (should be theme_links__system_main_menu).
  • ( phptemplate )
  • divs ul li

. Drupal: " HTML- Drupal"

+3

All Articles