Pages

Monday, November 16, 2009

Site Navigation in SharePoint


Navigation
is very important in any application. Navigation provides the way for the user to travel with in application.

Today I'll talk about Site Navigations in SharePoint.

  1. Global navigation (typically the top navigation)

  2. The current navigation (typically the left - hand navigation)


We can change the navigation by below two ways.

  1. Browser - Based Customizations


Publishing sites have a navigation customization capability through the browser. Navigating to the site’s Site Settings page and selecting Navigation under option. The Look and Feel section brings the user to the Site Navigation Settings page. From this page the site can be configured to include or exclude either sub sites and/or pages from the main navigation. In addition to the scoping options, owners can also select to manually or automatically sort navigation.

2. Changing Navigation Programmatically with the API
Below are custom Properties available with API.

1>  IncludeSubSites and IncludePages properties accept one of three values:
1.1> Always, 1.2> PerWeb, and 1.3>Never.

2> IncludeHeadings and IncludeAuthoredLinks properties are Boolean values that enable the site administrator to allow or block the inclusion of custom links and headings in the navigation.

We can add a new navigation code by using “Microsoft.SharePoint.Navigation.SPNavigationNode” class and then we need to add them in proper navigation collection.

Snippets code

SPWeb site = SPContext.Current.Web;


// get a reference to the top navigation


SPNavigationNodeCollection topNavigation = site.Navigation.TopNavigationBar;


// or get a reference to the Quick Launch navigation


// SPNavigationNodeCollection quickLaunchNav = site.Navigation.QuickLaunch;


// create new drop down menu in the navigation


SPNavigationNode newMenu = new SPNavigationNode(“External Links”, “”, false);


// add the new menu to the end of the top nav bar


topNavigation.AddAsLast(newMenu);


// add a custom link


newMenu.Children.AddAsLast(new SPNavigationNode(“Google”,“http://www.google.com”,true));



Let’s try something new into SharePoint other then out of the box functionality!

1 comment:

  1. Hi disha,

    Thanks for the info. i used to visit your blog everyday. i'm working as a sharePoint developer past 2 + years & i have experience in portal development using SharePoint designer. Now I'm learning WSS Object Model Programming. If you have any good materials or links for OBJECT MODEL Programming, pls mail me @ sureshkumar.c84@gmail.com.

    Thanks in advance...Nice bolg..keep updating the technology...

    Suresh.

    ReplyDelete