
If you have a small site with just a few pages, then you can see how it is OK to show an expanded and static left hand menu bar. However, if you have a more complex site structure with many pages, then you’ll absolutely want the left hand menu bar to show collapsed by default, with the Navigation Links appearing when the user mouses over a particular heading.
Telling SharePoint to Draw a Fly-out Menu
<SharePoint:AspMenu id="V4QuickLaunchMenu" runat="server" EnableViewState="false" DataSourceId="QuickLaunchSiteMap" UseSimpleRendering="true" Orientation="Vertical" StaticDisplayLevels="3" AdjustForShowStartingNode="true" MaximumDynamicDisplayLevels="0" SkipLinkText="" /> </SharePoint:SPNavigationManager>
Now you’ll need to tell SharePoint that instead of the default expanded menu view, you want just the headers to show, with an arrow beside those that can dynamically fly out to show sub-items when a user mouses over them. Here’s how you update the markup to do this:
- Change StaticDisplayLevels=”3″ TO StaticDisplayLevels=”1″
- Change MaximumDynamicDisplayLevels=”0″ TO MaximumDynamicDisplayLevels=”1″
Now save your change in SharePoint Designer and reload the Web site. You should see that your quick launch menu bar has turned into a fly-out menu.
Adding Some Style to your Fly-out Menu
The problem you’ll see now is that the fly out menu items are not styled in any way and can look like they all belong together like a run-on sentence. TSince tere is no physical separator to distinguish between each menu item, we’ll need to look into the SharePoint HTML markup to be able to style the look of the menu items so they are more user-intuitive.
Examining the SharePoint HTML
You will need to add custom CSS to style the fly-out menu items. Here is the default SharePoint HTML that each fly out menu item is rendered as:
<a title="Test stuff" class="dynamic menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" href="/sites/TestSite/SitePages/Menu Test.aspx"> <span class="additional-background ms-navedit-flyoutArrow"> <span class="menu-item-text">Conference Bridge Information</span> </span></a>
*** The Root Links ***
- Encapsulating Menu Div: <div class=”noindex ms-core-listMenu-verticalBox”
- Root UL: <ul class=”root ms-core-listMenu-root static”
- Root Li: <li class=”static dynamic-children”>
- Root text (followed immediately by the UL below for the fly-out hyperlinks: <a title=”root text”
*** The fly outs ***
- UL to encapsulate the fly-outs for a root link: <ul class=”dynamic” style=”z-index: 1100;”>
- Li to encapsulate the fly-out: <li class=”dynamic”>
- Fly-out hyperlink: <a title=”Test stuff” class=”dynamic menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode”
Steps to Format the Menu
Adding the CSS to Style your Fly-out Menu
<style type="text/css">
ul.ms-core-listMenu-root li ul li a.ms-navedit-linkNode{
background-color:white;
} ul.ms-core-listMenu-root li ul li a.ms-navedit-linkNode:hover{
background-color:#D8E3FF;
}
ul.ms-core-listMenu-root li ul li:first-child{
border-top:1px black dashed;
}
ul.ms-core-listMenu-root li ul li{
border-bottom:1px black dashed;
padding-bottom:3px;
min-width:150px;
}
</style>
Leave a comment