Aarebrot.net

Frodes website about Sharepoint and other stuff...

  • Increase font size
  • Default font size
  • Decrease font size

Customizing the Quick Launch and Navigation bars

E-mail Print
User Rating: / 3
PoorBest 

A question that I see quite frequently on the MSDN Sharepoint forums is how to change the number of levels that are displayed in the drop down menues. This can be easily done by changing some settings in the master page, but there are also a number of other things you can change if you tinker around a little bit.

Below is an example of a Top Navigation bar and a Quick Launch menu from a test site I created. As you can see there are a lot of properties for each of these two menu systems. Some of them are the same, and some of them are different.

  1. <SharePoint:AspMenu
  2.   ID="GlobalNav"
  3.   Runat="server"
  4.   DataSourceID="SiteMapDataSource1"
  5.   Orientation="Horizontal"
  6.   StaticDisplayLevels="1"
  7.   MaximumDynamicDisplayLevels="3"
  8.   StaticSubMenuIndent="0"
  9.   DynamicHorizontalOffset="0"
  10.   DynamicVerticalOffset="-8"
  11.   StaticEnableDefaultPopOutImage="false"
  12.   DynamicEnableDefaultPopOutImage="false"
  13.   ItemWrap="false"
  14.   CssClass="topNav">
  15.   <StaticMenuItemStyle CssClass="topNavItem" ItemSpacing="0"/>
  16.   <StaticSelectedStyle CssClass="topNavSelected" ItemSpacing="0"/>
  17.   <StaticHoverStyle CssClass="topNavHover"/>
  18.   <DynamicMenuStyle CssClass="topNavFlyOuts" />
  19.   <DynamicMenuItemStyle CssClass="topNavFlyOutsItem" />
  20.   <DynamicHoverStyle CssClass="topNavFlyOutsHover"/>
  21. </SharePoint:AspMenu>
  22.  
  23. <SharePoint:AspMenu
  24.   ID="CurrentNav"
  25.   runat="server"
  26.   datasourceID="SiteMapDS"
  27.   orientation="Vertical"
  28.   StaticDisplayLevels="2"
  29.   MaximumDynamicDisplayLevels="3"
  30.   StaticSubMenuIndent="1"
  31.   ItemWrap="true"
  32.   AccessKey="3"
  33.   CssClass="leftNav"
  34.   DisappearAfter="5000"
  35.   DynamicPopOutImageUrl="../../images/popout.PNG"
  36.   DynamicPopOutImageTextFormatString="Dynamic popout!"
  37.   StaticPopOutImageUrl="../../images/popout2.PNG"
  38.   StaticPopOutImageTextFormatString="Static popout!"
  39.   StaticBottomSeparatorImageUrl="../../images/navbarsep.PNG" 
  40.   StaticTopSeparatorImageUrl="../../images/navbarsep2.PNG">
  41.   <LevelMenuItemStyles>
  42.     <asp:MenuItemStyle CssClass="leftNav1" />
  43.     <asp:MenuItemStyle CssClass="leftNav2" />
  44.     <asp:MenuItemStyle CssClass="leftNav3" />
  45.   </LevelMenuItemStyles>
  46.   <StaticHoverStyle CssClass="leftNavHover"/>
  47.   <StaticSelectedStyle CssClass="leftNavSelected"/>
  48.   <DynamicMenuStyle CssClass="leftNavFlyOuts" />
  49.   <DynamicMenuItemStyle CssClass="leftNavFlyOutsItem"/>
  50.   <DynamicHoverStyle CssClass="leftNavFlyOutsHover"/>
  51. </SharePoint:AspMenu>

Orientation

There are two valid values here, horizontal and vertical. Quick Launch bars are usually vertical while the Top Navigation bars are usually horizontal, but you can change them up here if you want.

StaticDisplayLevels

This is where you set how many levels of navigation you want to always be visible. If you set it to 1, that means only the immediate sites are visible. If you set it to 2, then the immediate sites and their subsites are visible. This value can not be less then 1.

MaximumDynamicDisplayLevels

This is where you set how many levels of fly-out you want to appear when hovering over a menu item that has a subsite. If you set this value to 0, then no fly-outs will appear. If you set it to 3, then up to three levels of sub-sites will appear when hovering over sites that have subsites. This value can not be less then 0.

StaticSubMenuIndent

This property lets you indent statis sub-sites in a menu. The value is in pixels and must be greater or equal to 0. Note that you can also set indentation using padding in CSS, which is probably a better idea.

DynamicHorizontalOffset and DynamicVerticalOffset

If you need your drop down menues to appear slightly offset, you can use these two properties to move the point of where the drop downs appear. You can use both positive and negative values here. Positive values move the drop down or to the right, while negative values move menues up or to the left.

StaticEnableDefaultPopOutImage

If you don't want static menu items to display an arrow image if they have a sub-site, set this value to false.

DynamicEnableDefaultPopOutImage

If you don't want dynamic (fly-outs) menu items to display an arrow image if they have a sub-site, set this value to false.

ItemWrap

If an item is wider then the menu it is appearing in, you can set this value to true and it will wrap and break into a new line. If this is set to false, you'll have to take that into account when you make your CSS files. I had some issues with big long names breaking my design and using ItemWrap was the easiest fix for me.

CssClass

Sets the name of the CSS class that you can use to reference the entire menu in your CSS file. Usefull for setting a border around the menu, background colors or images, and that sort of stuff.

DisappearAfter

In terms of user friendlyness and usability this is one of the most important properties in my opinion. By adjusting this value you can set the time it takes for a drop down fly-out to dissapear after a user moves the mouse away from the drop down menu. I hate it when you're navigating some complex menu structure and you're about 5 levels deep when you accidentally move the mouse outside the boundary of the drop down and it closes the whole thing. Grr. Anyway, this value is measured in milliseconds so don't make it 1 or 2, but rather 1000 or 2000 (or more!).

DynamicPopOutImageUrl and DynamicPopOutImageTextFormatString

These two properties lets you set a custom image (and it's alternate text) to replace the default arrow when a dynamic (fly-out) menu item has a sub-site.

StaticPopOutImageUrl and StaticPopOutImageTextFormatString

These two properties lets you set a custom image (and it's alternate text) to replace the default arrow when a static menu item has a sub-site.

StaticBottomSeparatorImageUrl and StaticTopSeparatorImageUrl

These two properties let's you set custom images to appear before and after each static menu item. You're probably better off to not use these, and rather do such customization in a CSS file. That will give you more flexibility.

DynamicBottomSeparatorImageUrl and DynamicTopSeparatorImageUrl

These aren't actually in the code snippet above, but they do exist and does the same thing as the static ones except for dynamic menu items (fly-outs). Again as with the static ones you're probably better off doing this with CSS instead.

LevelMenuItemStyles

This let's you specify a custom CSS class for each level in a menu structure. I believe you can go as far down as you want here, but I haven't tried it out to check. It does work a little differently then the other properties though, so make sure you have a look at the code snippet above to see how the syntax works.

StaticHoverStyle

Let's you specify a custom CSS class for static menu items when they are hovered my the mouse.

StaticSelectedStyle

Let's you specify a custom CSS class for a static menu item that is selected (like if you're viewing that particular site).

DynamicMenuStyle

Let's you specify a custom CSS class for a dynamic (fly-outs) menu. This is the entire menu, not individual items.

DynamicMenuItemStyle

Let's you specify a custom CSS class for each item in a dynamic (fly-out) menu.

DynamicHoverStyle

Let's you specify a custom CSS class for an item that if being hovered over by a mouse in a dynamic (fly-out) menu.

Last Updated on Monday, 21 December 2009 12:27  
Comments (7)
Changing background color of 2nd level flyout
7 Wednesday, 10 February 2010 14:39
Todd
Well,..since I have conceded to just having one level of a flyout menu,...can someone tell me how to change the stark white background on that second level to another color? Seems like everywhere I look in SharePoint Designer's code....I can only alter the background color of the main QuickLaunch Menu,..but NOT the flyout.....
Flyout limitation
6 Wednesday, 10 February 2010 10:05
Todd
Frode,

maybe you are doing this from a different app? I'm going into Share Point Designer 07 and that is all that I'm using. I enter the coding section and alter the code.... Keep in mind that I do NOT have the Static Display Level coded in the actual html view....(it is not there).

I have to set that in the properties box to the left.... The MaxDynamic Display level is however there in the html view and I do have that one set according to your specs too.

After that,..all I do is hit save,.....close out SharePoint Designer and refresh the site.... Still only get the max of two....
Re: 3 levels not working...
5 Monday, 08 February 2010 16:16
Frode Aarebrot
Todd: You should be able to do as many levels as you want. I just tested with a basic site. I modified the BlueBand.master to have StaticDisplayLevels="2" and MaximumDynamicDisplayLevels="5", and uploaded the master page. I also made sure to check it in and to publish it.

I then created a bunch of sub sites, and I had successfully had 5 levels of fly-outs. I did some googling before that and I saw some other people saying the same as you, that 2 seems to be the max. I don't know why you're running into this limitation, but the control should be able to show as many levels as you want.

I suggest you try the same thing that I did, and then see if that works for you. Maybe there's some hotfix or service pack or something that fixes this issue, and I have it installed and you don't.
3 levels not working...
4 Thursday, 04 February 2010 16:02
Todd
Still not working....I'm hearing now that the Quick Launch Nav cannot be made to extend past 2 levels no matter what code is added/edited. Frustrating. So I guess I'll have to find another avenue...I have it set at Static 1 and Dynamic 4. Nothing.

Seems odd that it was made to not go past two levels.
Re: 3 levels...
3 Wednesday, 03 February 2010 13:39
Frode Aarebrot
It should have worked, but there might be something else that's messing with it.

What's your Static Level set to? I believe that they refer to the same levels, so if your static is set to 3 and your dynamic is set to 3, you don't get any fly-outs because 3 levels in total are already shown. So if you want 3 levels on top of what's already shown with static, you need to do static + 3. So if static is 1, set dynamic to 4. If static is 3, set dynamic to 6.

Let me know if you're still stuck.
3 levels not working...
2 Wednesday, 03 February 2010 12:51
Todd
Hello,..I seem to have no probs achieving the 2 level fly out menu for the Vertical Quick Launch modification,..but When I created a new page as a sub page to another, it does not appear as an additional fly out to the parent on the menu. All I get is the two levels but not the 3rd.

I have the Maximum Dynamic Display Levels set to 3 and it still won't show anything that I add as to a subsite to these 2nd levels.....what am I doing wrong? Is there a horizontal space limit or something on the flyout that I need to extend?

Any insight would be greatly appreciated.
StaticSelectedStyle not working
1 Wednesday, 08 July 2009 12:00
Jason
Since the beginning of branding my SharePoint site, the top navigation bar has failed to use the CSS I have assigned to the "StaticSelectedStyle" property. The main site works, but when I navigate to different sites along the top navigation bar, the selected tabs do not use the CSS that is referenced by "StaticSelectedStyle". Obviously this leads to the undesirable effect of the site always appearing to be on the main site even when you have navigated to the other sites. When messing around with the default.master, where this problem did not exist, I found that it broke once I activated "Office SharePoint Server Publishing Infrastructure" under Site Collection Features. Any ideas of why this happens? Any solution you've run across?

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification: