Welcome to MSDN Blogs Sign in | Join | Help

Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

In this post, I’ll show you how to customize the Quick Launch menu to display several levels of data in a dynamic way and use this customized menu for quick access to all Views within a List without consuming space on the Quick Launch.

First, let’s add a List and make sure it shows on the Quick Launch. Let’s call this list “Navigation Test List”, and then add 4 Views to the list.

Next, let’s write some OM code that, when run, adds a link to each of the List’s Views under the List Link on the Quick Launch. Add the following code to a new C# Console Application in Visual Studio .NET or 2005 (and don’t forget to add a reference to Microsoft.Sharepoint.dll).

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Navigation;

 

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            SPSite site = new SPSite("http://server");

            SPWeb web = site.OpenWeb();

            SPList list = web.Lists["Navigation Test List"];

            SPNavigationNode rootListLink = web.Navigation.GetNodeByUrl(list.DefaultViewUrl);

            SPNavigationNode node = null;

            foreach (SPView view in list.Views)

            {

                node = new SPNavigationNode(view.Title, view.Url, false);

                rootListLink.Children.AddAsFirst(node);

            }

        }

    }

}

 

At this point, we have links to all of the Views under the List, but they cannot be displayed since the menu control ignores the links after the second level. So, let’s modify the menu control to display what we want. Perform the following to accomplish this task:

 

1.     Navigate to the master page gallery: From the home page click on Site Actions, then Site Settings, and then on Master Pages, under the Galleries column

2.     Click on the drop down menu for the master page you want to modify, and then click on Edit in Microsoft Office SharePoint Designer

3.     Locate the Quick Launch Menu control, and modify the StaticDisplayLevels and MaximumDynamicDisplayLevels attributes:

                     <SharePoint:AspMenu

                            id="QuickLaunchMenu"

                            DataSourceId="QuickLaunchSiteMap"

                            runat="server"

                            Orientation="Vertical"

                            StaticDisplayLevels="2"

                            ItemWrap="true"

                            MaximumDynamicDisplayLevels="1"

                            StaticSubMenuIndent="0"

                            SkipLinkText="">

                           

4.     Save your changes and reload the page from the browser. Hover over the Links on the Quick Launch. The end result should look like this:

 

5.     Optional: Modify other properties in the menu control to match the look and feel of your site. The above steps can also be applied to the Top Link Bar.

 

Useful Links:

·         On MSDN, How to: Customize the Display of Quick Launch.

 

 

Luis Angel Mex

SDET

Published Thursday, April 26, 2007 4:49 PM by sptblog

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Assumes you have Visual Studio .NET or 2005.

Friday, April 27, 2007 4:41 AM by Neil

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Thanks for the post, seems like everyone I work with wants their own navigation. Do you have any idea how to make this work:

http://msdn2.microsoft.com/en-us/library/ms466994.aspx

I have tried walking through this tutorial and it just doesn't work.

Friday, April 27, 2007 11:07 AM by Braden Callahan

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hi

I have created one document library by C# code

but unable to display it on quick launch

could you help me out in this

please mail me yvanera@sapient.com

Wednesday, May 02, 2007 6:55 AM by Yogesh Vanera

# SharePoint Kaffeetasse 08

Upgrade und Migration How to Upgrade an Area based on a Custom Site Definition Upgrade Link-Übersicht

Wednesday, May 02, 2007 8:21 AM by SharePoint, SharePoint and stuff

# Sharepoint Weekly 4

Fellow blogger Amanda Murphy is INETA president elect ! The SharePoint Solutions Blog releases the Site

Friday, May 04, 2007 1:52 AM by Arno Nel 2.0 - the Strategic Architect

# SPPD072 SharePointPodcast

Direkter Download: SPPD-072-2007-05-07 [00:00] Intro Windows 386 Promo Video [00:00] Themen Interactive

Monday, May 07, 2007 9:35 AM by SharePointPodcast.de

# SPPD072 SharePointPodcast

Direkter Download: SPPD-072-2007-05-07 [00:00] Intro Windows 386 Promo Video [02:21] Themen Interactive

Monday, May 07, 2007 9:39 AM by SharePoint, SharePoint and stuff

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Thanks for the post, it's just what I need... but, I don't know where the code or DLL must be placed... can you explain it please?

Friday, May 11, 2007 3:58 AM by Francisco Javier

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Excellent article just what I needed!

One question: How to modify this sample to add links under subsites in Sites section?

I've tried your samle and added subsite named 'subsite' and tried to modify line:

SPNavigationNode rootListLink = web.Navigation.GetNodeByUrl("/subsite/default.aspx");

but added links appear only in Top link bar not under subsite in Quicklaunch.

Sunday, May 13, 2007 7:09 AM by Danielz

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hi,This is fine, but what is the way to add javascript in this quick launch thing.

Monday, May 14, 2007 3:41 AM by Yadnesh

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

All right, here are some answers to your questions:

1. To perform these actions, you don't need VS 2005 or Sharepoint Designer. Notepad should be enough to modify the Master Page :)

2. The Object Model code should live in a WFE, and it can be anything from a console, window app or dll that's called from another app. Just create a new app in VS, add a reference to Microsoft.Sharepoint.dll, and add the code above to your .cs file. More info on OM programming can be found here: http://msdn2.microsoft.com/en-us/library/ms430674.aspx

3. To add links under the headings in the Quick Launch, replace the following line of code:

SPNavigationNode rootListLink = web.Navigation.GetNodeByUrl(list.DefaultViewUrl);

for:

SPNavigationNode rootListLink = web.Navigation.GetNodeById(1026);//or the Id of the node under which you'll add the links

There's an upcoming post that details the differences in the way we handle some URLs and why sometimes GetNodeByUrl doesn't work as expected...

Monday, May 14, 2007 3:55 PM by angelmex

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

The SDK article in http://msdn2.microsoft.com/en-us/library/ms466994.aspx has some mistakes and omissions in the task related to create a custom masterpage:

Step 4 should be split in 2. First, create the new subsite, and upload the new master page in there. Then run the code to set the .MasterUrl property.

Also, the italic tags are confusing. I'll report these mistakes and get a better document out. Thanks for the catch!

Monday, May 14, 2007 4:35 PM by angelmex

# re: Customizing the Quick Launch menu: Modify the background image

Hi,

I am currently trying to have a single image as the background which takes in the ms-leftareacell/ms-titlearealeft area, and set the Quick Launch Menu background to be transparent but the list/items to display.

This is so that the background image image will butt against my ms-bannerframe image to form a seamless top and LHS image.

I have tried various permutations in my theme.css, but can't seem to make it work.

Has anyone been here before ?.

The top of my ms-leftareacell image is the bottom half of a circle, which needs to butt onto the top half of a circle in my ms-bannerfarme image.

Thanks in advance for any help I can receive.

Friday, June 01, 2007 4:50 AM by jim.beck@chivas.com

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hellu!

I think this post is exectly what I'm looking for. But it turns out, I'm a total ASP-Noob, so

can someone please explain in a more detailed way what to do with the OM-Code?

Compile it in a dll an sign it, and now? Where shall I put/install it? (GAC?) And how does the server know that it should use it?(XML-Config?) (What is the "WFE"?)

Would appreciate your help. Thx in advance!

Homerhirn.

Thursday, June 14, 2007 7:00 AM by Homerhirn

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hi,

I got a question about the top navigation bar. No matter what I do the current site is always the first link highlighted on the left side.

We would like to have the top navigation look the same on every site collection, meaning that there are the four links (Home, Organisations, Projects, Knowledge Base) on every site in that order without the current site collection highlighted on the left.

Any ideas?

Friday, August 03, 2007 4:04 AM by Thimo

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

I have tried to get that 3rd level of menu to appear in the flyouts with no success. How do you tell it what to display there. Is it possible in the Nav settings gui or do you have to do in OM

Thursday, August 23, 2007 4:11 PM by chris

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hi, I have the dynamic menus going fine (thanks!). The background is white, no matter what theme I use. The theme I want to use has white text, so the menus are unreadable. Any ideas on how to change the background colour?

Monday, September 10, 2007 3:02 AM by Andrew

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

This flyout menu does not work in Firefox.. any workarounds?

Monday, September 17, 2007 1:20 PM by Jack

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

I'm trying to incorporate a tree view in my sharepoint site. The look needs to be how an asp:treeview control would render the tree - with expand-collapse and subnodes appearing below the parent node instead of to the right (as shown above).

Tuesday, October 30, 2007 4:22 PM by ndesh2

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

I found it DOES work in firefox, but some of the css styling is causing the fly-outs to display strangely. In the master page, below the quick launch menu control listed above, is this:

<LevelSubMenuStyles>

<asp:SubMenuStyle CssClass="ms-navSubMenu1"/>

<asp:SubMenuStyle CssClass="ms-navSubMenu2"/>

</LevelSubMenuStyles>

I removed the second entry for

<asp:SubMenuStyle CssClass="ms-navSubMenu2"/>

and the fly-out now displays fine in Firefox and Safari.

Wednesday, October 31, 2007 2:54 AM by KieranK

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Can we implement role based quick launch, means make menu item enable disable based on User Role

Thursday, December 20, 2007 6:25 AM by Prashant

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

I'd be interested on the same thing as Prashant. Has anyone got any ideas how to approach this "problem" :)

Thursday, January 03, 2008 8:17 AM by HH

# How to make a "Super Menu" control for SharePoint

Note: These instructions apply to MOSS 2007. It's tinier than the Quick Launch area, more powerful than

Monday, February 11, 2008 4:41 PM by Eric Legault My Eggo

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hi,

I am conparitively new to sharepoint. I want to implement Flyout menu for navigation which i did successfully.

Now, i want to change the behaviour of the left navigation i.e when a user goes to a menu, its child menus are displayed. This is the default behaviour of the menu. Here i want to highlight the parent menu i.e. user should know which menu is the parent menu for the child menus he is looking into?

In short i want to know how to highlight the parent menu items.

I will appreciate any help in this regards.

Thanks,

Sandeep

Wednesday, March 12, 2008 9:00 AM by Sandeep

# SharePoint APAC Conference and recent articles

Body: I have been getting ready for my presentation at the APAC conference . I will do a solo session

Monday, March 17, 2008 2:08 PM by Mirrored Blogs

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hi luis,

Its very useful blog...

I've tried in my portal home page.its working fine.but i dont know why half of the words are hiding behind the body of the site?

Thursday, March 20, 2008 1:41 AM by karthik

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Hi,

I am able to implement fly out menus successfully but when i login with admin credentials i am able to see. When i login with the viewer or member rights the popoutmenus and the arrow don't appear.

Any help on this would be very useful.

Thanks,

Meghna

Thursday, April 03, 2008 1:20 AM by Meghna

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

I've created a Navigation like shown at the top of the page and it is more comfortable for our Sharepoint. But I've still one question. When I want to change the Style, I cannot find a style element in the core.css for the 3rd level. At the picture on the top of the page the items are blue like links, like my problem. which css-element I have to change to get the same text-color like the items on the higher levels?

Friday, April 11, 2008 3:59 AM by Manuel Schön

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Does anyone have a solution for the styling problem of the subsite headers? First of all the bullet comes as a dublicate and the width varies depending how you navigate.

Monday, April 14, 2008 6:47 AM by Lauri V

# Deleting Flyouts from QuickLaunch Menu in SharePoint

Here is the code that I created to delete the flyouts, if you install them as Luis advised:

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Navigation;

namespace FlyOutDelete

{

   class Program

   {

       static void Main(string[] args)

       {

           SPSite site = new SPSite("http://yourweb");

           SPWeb web = site.OpenWeb();

           SPList list = web.Lists["TestList"];

           SPNavigationNode rootListLink = web.Navigation.GetNodeByUrl(list.DefaultViewUrl);

           SPNavigationNode node = null;

           foreach (SPNavigationNode curnode in rootListLink.Children)

           {

     curnode.Delete();

   }

  SPNavigationNode thisnode = rootListLink.Parent;

  thisnode.Delete();

       }

   }

}

Friday, April 18, 2008 5:33 PM by LaShelle Cline

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

In the previous post, this line of code:

thisnode.Delete();

will delete the parent node (meaning the list link will no longer show up in the Quick Launch menu), so you will have to relink your SharePoint List in the Quick Launch menu by going to the List Settings->"Title, description, and navigation" and make sure the "Display this list on the Quick Launch?" Yes radio button is chosen. This is only needed if you chose to add the line of code above.  I created this console application in Visual Studio 2005 so it would delete the flyouts that linked to custom SharePoint pages instead of only built-in list views.  As you can imagine, deleting my tests was a necessity because my first few attempts did not work out as expected.  Basically I was creating linked node lists that linked to other node lists; I needed the ability to delete the parent nodes until all of the flyouts were gone.  I will also share the code I used to add custom links to my client's SharePoint site soon.

Saturday, April 19, 2008 3:16 AM by LaShelle Cline

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

how to create a link in the quick launch to create a new document in a document library?

Wednesday, May 21, 2008 7:57 AM by erugalatha

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Well, if you don't care if the link is a fly-out link, you can add custom links to your Quick Launch by going to Site Settings->Quick Launch, and add a new link or heading. To get the correct URL, navigate to the document library and click on Upload, and then copy the URL it takes you to.  Remember to remove everything after upload.aspx.

Thursday, June 05, 2008 5:50 PM by LaShelle Cline

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Sorry, didn't read your comment carefully.  Instead of going to "Upload" in your document library, you would just take the URL of your document library and concatenate /Forms/template.doc (or whatever file extension you used for your new documents).  So if your document library was called "Shared", your URL would look something like http://MySharePointSite/Shared/Forms/Template.doc.

Thursday, June 05, 2008 5:55 PM by LaShelle Cline

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Please could someone tell me how to automatically get newly created sub-sites to be under (or fly out) of the Sites heading.  All my subsites show as headings on quicklaunch unless I manually move them under the Sites heading.

Friday, June 13, 2008 10:25 AM by Ian Vaughan

# WSS3SDK之:定制导航和新的用户界面元素

WSS3.0在导航方面为用户提供了许多令人振奋的新功能,用于提升用户对站点上下文的感知。分别位于顶部左侧和页面中间区域的两个新的面包屑导航(breadcrumb)控件为用户提供了当前网站上层和内部站...

Friday, June 20, 2008 6:34 AM by Sunmoonfire

# re: Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

Thanks I can get the 2 tier fly out menus working for views. Is there a way to apply the same principle to folders in a document library insetad of views?

Monday, August 18, 2008 2:41 AM by Lee

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker