Next Tutorial

Drupal 7 Tutorial Part 15: Drupal 7 Advanced Taxonomy Concepts

Drupal 7 Tutorial Part 8: How to create a menu and add links to it in Drupal 7

Submitted by anilsagar on Tue, 05/31/2011 - 20:53

Hi Drupalers,

In last tutorial , we learnt about drupal 7 default menus and different menu settings. In this tutorial we will see how to create a new menu from scratch and how to add new links to the menu.

Let's create a menu with links to some of commonly used administrative links and display only to administrators. This menu will help to quickly navigate to the links.

Creating new menu:

  • Login as administrator and goto home page. Click on Structure link on top main menu. Then, click on Menus link.
  • Now you will screen some thing like below.

  • In the above screen, click on Add menu link to create a new menu. Once you click on Add menu link you will screen some thing like below.
  • We need to provide title and description for our new menu. Let's title the menu as Administration Shortcuts and give description as This menu is used to navigate quickly to most commonly used administrative links. Now click on save button below the form. Once you save the form you will see the screen something like below. Screen shows with a status message  "Your configuration has been saved."

  • Let's add some links to our new menu and see some advanced settings while adding links. Click on Add link text as shown in above screen to add a new link to our menu.
  • Once you click on add link you will see screen something like below to create a new link.

  • Let's create a link to listing of blocks page. Link is "admin/structure/block" . Fill the Menu Link title as "Blocks Landing Page", path as "admin/structure/block", Description as "Blocks listing page", and click on save. You can see confirmation message "Your configuration has been saved" and now you are in our new menu "Administration Shortcuts" links listing page.
  • You can see Add Link text in the listing page. click on that link to add one more link to our "Administration Shortcuts" menu.
  • Let's add link to "User listing" page. Path to this page is "admin/people".  Give title as "User Listing", description as "List of all users". Click on save. We just added two links to our menu.
  • Now you can see two links in menu listing. Now let's enable this menu for administrators in the left side bar.
  • Normally, when we create a menu, Drupal automatically creates a block that displays our menu links. So, when ever a menu is created with link a block will be automatically created for that menu.
  • Let's go to block listing page, to enable our menu which is block format. Click on                           Structure >> Blocks to access blocks listing page. In the blocks listing page when you scroll down you can see Administrative Shortcuts block in the disabled section like in below screen.

  • Let's enable Administration shortcuts in left side bar and only for administrators. As you see in above screen, change the select box value next to "Administrative Shortcuts" text from - None - to  sidebar first. When you change the value the row will be automatically moved to Sidebar first section in block listing page. Only when you click on "Save blocks" button at bottom then only settings will be saved. Click on save blocks button to save settings.
  • Now go to home page to see our new menu in the left side bar. If you want to enable this block only for administrators go to block configure page from block listing then set visibility conditions to  only administrators. My previous tutorial will help you, to set visibility permissions only to administrators.

  • So, we created a menu from scratch and displayed it using block in the left side bar.
  • If you want to add more links to the same menu, go to Structure >> Menus >> Add Link (Next to Administrations Shortcuts in the list of menus) .

Let's see more menu settings, parent child relation ship of menus, changing order of menus, global menu settings in my next tutorial. Stay tuned with me.

Please feel free to comment if you have any issues.

Cheers,

Anil Sagar

 

10 comments

link to the menu while creating an article

Submitted by sivan (not verified) on Wed, 02/01/2012 - 09:35.

thanks for the information..
it is possible to link your new article to the menu... isn't??
my problem is that i have created new menus, but while creating menu link these newly created menus doesn't appear..
Anybody have a solution??

Just one work: GREAT!!

Submitted by Franco (not verified) on Fri, 01/06/2012 - 20:32.

Just one work: GREAT!!

Thanks!

Submitted by Albert (not verified) on Thu, 01/05/2012 - 07:06.

Hi Anil,
Just had to say thanks for all these...they are easy to understand, simple to learn...just very good.
Thanks,
Albert

My Question

Submitted by fareed (not verified) on Fri, 12/09/2011 - 14:56.

First of all Thanks a lot for sharing knowledge. My question is " I want to create different links for different topics like on PHP, HTML, CSS etc. They should be stored in their own link which will lead to the relevant page. I am unable to do that. Moreover I made 4 links but they were not shown till the time i am logged in as admin.
Kindly guide

Great post. Following the

Submitted by Anonymous (not verified) on Tue, 10/25/2011 - 09:24.

Great post.
Following the directions you listed, how would i add a link to a users account/edit page? The link would be site/user/2/edit for one user and site/user/3/edit for another user. I am assuming it involves some kind of variable but I cannot figure it out.

Thanks

Use Menu Token Module

Submitted by anilsagar on Tue, 10/25/2011 - 22:40.

Hi,

Menu token module will solve your problem. http://drupal.org/project/menu_token

Thank you :-)

Great article

Submitted by Pierre (not verified) on Sun, 09/25/2011 - 22:47.

Thank you so much , I have struggled so much with that.
Your article was well needed.
By the way great blog too, I book it

Cheers

Thanx for this tutorials

Submitted by Mukund (not verified) on Sat, 07/02/2011 - 03:18.

Thanx for this tutorials

hey thanks for wonderful

Submitted by Kalpesh (not verified) on Fri, 06/10/2011 - 16:58.

hey thanks for wonderful posting.
here I want to add image with menu, so how to do that?
can we add any extra field to database & customise form ?
please help........

Hi Kalpesh

Submitted by anilsagar on Fri, 06/10/2011 - 22:48.

This is the neat and quickest solution. http://chrisshattuck.com/blog/how-use-images-menu-items-drupal-simple-pr....

Cheers,
Anil Sagar

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.
©2010 AnilSagar. All rights reserved. Drupal theme by Kiwi Themes.