Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

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 7589

Trending Articles



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