Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation
2010-11-07 12:36
549 查看
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:
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
Click on the drop down menu for the master page you want to modify, and then click on Edit in Microsoft Office SharePoint Designer
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="">
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:
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.
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:
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
Click on the drop down menu for the master page you want to modify, and then click on Edit in Microsoft Office SharePoint Designer
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="">
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:
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.
相关文章推荐
- Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation
- Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation
- 转载:Hiding the Quick Launch in SharePoint 2010——在sharepoint2010中隐藏快速启动栏
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- Adding Custom Actions to the List Item Menu in SharePoint 2010 Using SharePoint Designer 2010[Sharepoint中添加自定义菜单]
- How to Pin or Unpin a Program to the Windows 7 Taskbar (Shorcut quick launch)
- How to move the databases that are used by SharePoint Portal Server 2003 to a computer that is running SQL Server
- SharePoint Debug - Failed to load resource: the server responded with a status of 500
- Access denied error by access to a txt file on the sharepoint server
- ({i:0#.w|nt authority\iusr})Sharepoint impersonates the IUSR account and is denied access to resources
- 关于iOS 真机不能调试process launch failed: timed out waiting for app to launch 和 failed to get the task for
- 转:How to submit the rows of a repeating table in InfoPath to a SharePoint list
- Using the ForeFront Identity Manager to Configure SharePoint 2010’s User Profile Sync Service
- sharepoint failed to connect to the configuration database错误
- SharePoint debug : launchPoint given is already associated with a callout
- 【oneday_onepage】——Microsoft adds a wing, more closets to the homes of SharePoint Online tenants
- SharePoint Project Deployment Fails With Error "Failed to extract the cab file in the solution"
- Customizing and Extending the SharePoint 2010 Server Ribbon
- How to remove the ribbon tabs in list forms in SharePoint 2010