This blog describes about how to add a new menu item into menu like main menu, user menu in drupal 7.
We can create a menu item using hook_menu in drupal 7. Can we add menu item into already created menu in drupal7? Yes you can add a link into menu using hook_menu().
Add new menu item into main menu in drupal 7:
Consider below program to add new menu item into main menu in drupal 7.
/**
* Implement hook_menu()
*/
function phponwebsites_menu() {
$items['sample'] = array(
'title' => t('Sample page'),
'type' => MENU_NORMAL_ITEM,
'menu_name' => 'main-menu',
'page callback' => 'samplepage',
'access callback' => TRUE,
);
return $items;
}
/**
* Implement samplepage()
*/
function samplepage() {
$str = t('Hi this is sample page');
return $str;
}
* Implement hook_menu()
*/
function phponwebsites_menu() {
$items['sample'] = array(
'title' => t('Sample page'),
'type' => MENU_NORMAL_ITEM,
'menu_name' => 'main-menu',
'page callback' => 'samplepage',
'access callback' => TRUE,
);
return $items;
}
/**
* Implement samplepage()
*/
function samplepage() {
$str = t('Hi this is sample page');
return $str;
}
Where,
type – MENU_NORMAL_ITEM
menu-name – name of the menu to add new link
You need to clear cache to see created new menu item in main menu. Now i’ve hope you know how to add new link programmatically to already created menu in drupal 7.
Thanks for the tutorial. It really works!
ReplyDeleteWould far past anybody's doubts have the decision to make on faint spot interests! Welcome to here you'll observe how it should look. dark0de market link
ReplyDeleteWell… I discharge up web diaries on an on an amazingly boss level disturbing from issue, at any rate I never visited your blog. I added it to populars other than i'll be your experiencing beating. dark0de market url
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIn any case, a website stays an interest in time and cash. onohosting.com/
ReplyDeleteAsk your SEO Organization what methods they utilize for social occasion backlinks.
ReplyDeletewww.ryancameron.me