Customizing Navigation Controls and Providers
To customize navigation, you should rely on the ASP.NET Site Navigation mechanism, because it provides a standard, consistent, and easily managed solution.
Customizing Web Display Controls (Menu, TreeView, and SiteMapPath) :
You can customize the look and feel of standard display controls by using cascading style sheets (CSSs). You can also write your own ASP.NET 2.0 controls and use them in Office SharePoint Server 2007 navigation. To learn more, see the Menu class documentation.
Note: Office SharePoint Server 2007 also provides default navigation components that you can customize, such as the Content By Query Web Part and the Table of Contents Web Part. You can configure these two controls to present a custom selection of links.
To implement your own site map provider, you can derive a custom provider class from any of the default site map providers. Office SharePoint Server 2007 includes several default providers. You can also derive a custom provider class from the SiteMapProvider class in the System.Web namespace. However, deriving the Office SharePoint Server 2007 site map providers supplies several additional benefits such as navigation node caching and security trimming. Therefore, you should use the Office SharePoint Server 2007 caching and security trimming infrastructure instead of writing your own caching and security trimming in a custom provider by deriving from the default providers. Although the site map provider classes have approximately twenty abstract or virtual methods, only a small number must be overridden and implemented in a custom site map provider. The following code example derives from the PortalSiteMapProvider class and demonstrates how to add items to the site map provider.
public class CustomNavProviderWithList : PortalSiteMapProvider {
public override SiteMapNodeCollection
Customizing Web Display Controls (Menu, TreeView, and SiteMapPath) :
You can customize the look and feel of standard display controls by using cascading style sheets (CSSs). You can also write your own ASP.NET 2.0 controls and use them in Office SharePoint Server 2007 navigation. To learn more, see the Menu class documentation.
Note: Office SharePoint Server 2007 also provides default navigation components that you can customize, such as the Content By Query Web Part and the Table of Contents Web Part. You can configure these two controls to present a custom selection of links.
To implement your own site map provider, you can derive a custom provider class from any of the default site map providers. Office SharePoint Server 2007 includes several default providers. You can also derive a custom provider class from the SiteMapProvider class in the System.Web namespace. However, deriving the Office SharePoint Server 2007 site map providers supplies several additional benefits such as navigation node caching and security trimming. Therefore, you should use the Office SharePoint Server 2007 caching and security trimming infrastructure instead of writing your own caching and security trimming in a custom provider by deriving from the default providers. Although the site map provider classes have approximately twenty abstract or virtual methods, only a small number must be overridden and implemented in a custom site map provider. The following code example derives from the PortalSiteMapProvider class and demonstrates how to add items to the site map provider.
public class CustomNavProviderWithList : PortalSiteMapProvider {
public override SiteMapNodeCollection
GetChildNodes(System.Web.SiteMapNode node) {
PortalSiteMapNode portalNode = node as PortalSiteMapNode;
if (portalNode != null)
{
if (portalNode.Type == NodeTypes.Area)
{ SiteMapNodeCollection nodeColl = base.GetChildNodes(portalNode);
using (SPSite currentSite = new SPSite(portalNode.Url))
{ SPWeb currentWeb = currentSite.OpenWeb();
SPListCollection lists = currentWeb.Lists;
foreach (SPList list in lists)
{ string listUrl = list.DefaultViewUrl;
PortalSiteMapNode childNode =
new PortalSiteMapNode(webNode,
PortalSiteMapNode portalNode = node as PortalSiteMapNode;
if (portalNode != null)
{
if (portalNode.Type == NodeTypes.Area)
{ SiteMapNodeCollection nodeColl = base.GetChildNodes(portalNode);
using (SPSite currentSite = new SPSite(portalNode.Url))
{ SPWeb currentWeb = currentSite.OpenWeb();
SPListCollection lists = currentWeb.Lists;
foreach (SPList list in lists)
{ string listUrl = list.DefaultViewUrl;
PortalSiteMapNode childNode =
new PortalSiteMapNode(webNode,
listUrl, NodeTypes.custom, list.Title, listUrl, null);
nodeColl.Add(childNode);
} }
return nodeColl;
} else { return base.GetChildNodes(portalNode);
} }
else { return new SiteMapNodeCollection(); } } }
Cheers...
} }
return nodeColl;
} else { return base.GetChildNodes(portalNode);
} }
else { return new SiteMapNodeCollection(); } } }
Cheers...
Comments
Post a Comment