Поделиться через


WSS 3.0 : Adding links to the quick launch bar

Microsoft.SharePoint.Navigation API allow us to add new link to the quick launch bar of your site. The sample code in the SDK is as follows.

 

SPSite siteCollection = SPControl.GetContextSite(Context);

SPWeb site = siteCollection.AllWebs["TestSite"];

SPWeb subSite = site.Webs["SubTestSite"];

 

SPNavigationNodeCollection nodes = subSite.Navigation.QuickLaunch;

SPNavigationNode navNode = new SPNavigationNode("New Link", "https://www.msn.com", true);

nodes.AddAsFirst(navNode);

 

 

Question #1 : How can I add links to my subsites?

 

                You can add the links to your subsites for your site as below.

SPNavigationNode navNode = new SPNavigationNode("New Link", "subsite1/subsite2", true);

 

                The result will be https://<server>/sites/ TestSite/Subsite1/subsite2

 

Question #2: How can I add links to the external site?

 

SPNavigationNode navNode = new SPNavigationNode("New Link", "https://www.msn.com", true);

 

Note : Its mandatory that you have to use “http” (or any other protocol specifier) in the url parameter to specify the external url. Other wise it will be treated as a relative path. Say if you pass, “www.msn.com”, then the result will be TestSite/www.msn.com. so the protocol specifier should be used in the URL.

Comments

  • Anonymous
    September 13, 2007
    2007 MOSS Resource Links (Microsoft Office SharePoint Server) Here is an assortment of various 2007 Microsoft

  • Anonymous
    February 18, 2008
    Gracias a Mark Kruger (SharePoint MVP) por esta lista de recursos de SharePoint donde podréis encontrar

  • Anonymous
    May 21, 2008
    Hi... is it possible to hide the links in the quick lauch? i tried using isVisible property but that doesnot seem to work