Quantcast
Channel: SharePoint 2013 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 21070

How exclude subsites in global navigation from c# code

$
0
0

 Hi,

I need show Global navigation items in custom web part, below code is returning global navigations with sub sites. 

how to exclude sub sites and return only global navigation items links?

using (SPSite spsite = new SPSite(SPContext.Current.Web.Url))
                {
                    using (SPWeb web = spsite.OpenWeb())
                    {                                           
                        PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);                                       
                        SPNavigationNodeCollection colletion = pubWeb .Navigation.TopNavigationBar;
                        foreach (SPNavigationNode navigationNode in colletion)
                        {

//Getting all global navigation nodes including sub sites

}

}

}

Thanks.




Viewing all articles
Browse latest Browse all 21070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>