How to:Extend the Navigation Provider
- Create a Microsoft Visual C# class library project with following code, add the required references, and then build the project.
using System;using System.Collections.Generic;using System.Text;using Microsoft.SharePoint.Publishing;using Microsoft.SharePoint.Publishing.Navigation;using System.Web;using System.Web.UI.WebControls;using System.Configuration;
namespace MyCustomNav
{
public class Navigation: PortalSiteMapProvider
{
public override SiteMapNodeCollection
GetChildNodes(System.Web.SiteMapNode node)
{PortalSiteMapNode pNode = node as PortalSiteMapNode;
if (pNode != null)
{if (pNode.Type == NodeTypes.Area)
{SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode);
SiteMapNode childNode = new
SiteMapNode(this, "
"
SiteMapNode childNode1 = new
SiteMapNode(this, "
"
"Support");nodeColl.Add(childNode);
SiteMapNodeCollection test = new
SiteMapNodeCollection();test.Add(childNode1);
childNode.ChildNodes = test;return nodeColl;
}elsereturn base.GetChildNodes(pNode);
}elsereturn new SiteMapNodeCollection();
}}}
- Copy the .dll file you created in step 1, and then paste it into the Office SharePoint Server 2007 virtual directory’s bin folder.
- Create the following entry in the web.config file for the Web application, and then set the trust level to Full.
<add name="MyCustomNavigationProvider" type="MyCustomNav.Navigation, MyCustomNav"
NavigationType="Current"/>
- Create a custom master page and add the following code under the top navigation’s ContentPlaceHolder element.
<sharepoint:aspmenuid="topnavigationmenu" runat="server" datasourceid="topSiteMap1" enableviewstate="false" accesskey="">" Orientation="Horizontal" StaticDisplayLevels="1" MaximumDynamicDisplayLevels="3" DynamicHorizontalOffset="0" StaticPopoutImageUrl="/_layouts/images/menudark.gif" StaticPopoutImageTextFormatString="" DynamicHoverStyle-BackColor="#CBE3F0" SkipLinkText="" StaticSubMenuIndent="0" CssClass="ms-topNavContainer">
<staticmenustyle/><staticmenuitemstyle cssclass="ms-topnav" itemspacing="0px"/><staticselectedstyle cssclass="ms-topnavselected"/><statichoverstyle cssclass="ms-topNavHover"/><dynamicmenustyle backcolor="#F2F3F4" bordercolor="#A7B4CE" borderwidth="1px"/><dynamicmenuitemstyle cssclass="ms-topNavFlyOuts">
<asp:sitemapdatasource showstartingnode="False" sitemapprovider="MyCustomNavigationProvider" id="topSiteMap1" runat="server" startfromcurrentnode="true">
- Reset Microsoft Internet Information Server (IIS). Your SharePoint site should now show the updated navigation from the extended navigation provider.
Still more to come...
Cheers...
Comments
Post a Comment