Replacing the Main Menu In Drupal Bartik Sub-theme

The main menu in Drupal 7 - Bartik theme or subsequent sub-theme shows only the primary links, you can't add the secondary links or view in a hierarchal mode, to do this a module called Nice Menus comes in very handy.

Download and install and enable the module to:

sites/all/modules/nice_menus

By default 2 menus will be made available for positioning, to increase this number edit the number in the Modules > Nice Menu.

You position these menus in Structure > Blocks, by default they are set to 'none' for a region, just select an availabe region and then the menu appears there.

This may be OK for some but others will want more granular control over the menu, how about actually replacing the default menu and postioning the new menu more accurately. To do this you will need to  make a copy of the 'page.tpl.php' file in your theme or sub-theme copy from this location to yours:

modules/system/page.tpl.php

Edit the page.tpl.php and replace the content in between the

 <div id="main-menu" class="navigation"> </div>

Replace what is there:

<?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Main menu'))); ?>

 

...with the Nice Menu php, add in options if required ie direction can be also left or right.:


<?php
// id, direction, depth should have the values you want them to have.
  $menu = theme('nice_menus', array('id' => 0, 'direction' => 'down', 'depth' => 2, 'menu_name' => 'main-menu', 'menu' => NULL));
  print $menu['content']; ?>

That will get it on the page.

To style the menu with CSS copy the file below to your theme's  folder.

sites/all/modules/nice_menus/nice_menus_default.css

Then Declare this path in Admin > Appearance

css-path-drupal-nice-menu

 

 And style away.