Menu

Add Dropdown for Main Menu in Drupal7

hello friends,

if you want to add drop down to main menu item then open your template.php file of your theme

Replace below code


if (isset($vars['main_menu'])) {
$vars['primary_nav'] = theme('links__system_main_menu', array(
'links' => $vars['main_menu'],
'attributes' => array(
'class' => array('links', 'inline', 'main-menu'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
)
));
}else{
$vars['primary_nav'] = FALSE;
}

By below code


if (isset($vars['main_menu'])) {
$pid = variable_get('menu_main_links_source', 'main-menu');
$tree = menu_tree($pid);
$tree = str_replace(' class="menu"', '', $tree);
$vars['primary_nav'] = drupal_render($tree);
}else{
$vars['primary_nav'] = FALSE;
}

Use below code to where you want to dispaly main menu


<?php
if ($primary_nav): print $primary_nav; endif; 
?>

No comments

Leave a Reply


× 4 = 36

Categories