Showing posts with label Site Navigation. Show all posts
Showing posts with label Site Navigation. Show all posts

Tuesday, August 20, 2013

Site Navigation does not show the subsites

Yes. It happened to us where one WFE shows all the sub sites in the "Navigation" options under "Navigation Editing and Sorting" whereas another WFE was showing all the sub sites correctly. Dues to this the navigation menu is different between the servers.

On researching on this issue we did not hit any pages at all but one. We tried what is told in that post as well. Tried to reset the Global Navigation to same as Parent Site and came back to the page to find out nothing shows up still.


Since we did a recent migration to a new server we thought some clock might have got out of sync in one of our servers and it affected the navigation system and decided to re-deploy the package again.

Re-deploying the whole package must have cleared up any SP cache built up internally which made it to work. Until now we do not have any idea of what has happened or how it got fixed. We are good for now.

Please follow the steps mentioned in the above link if that does not work just do a re-deploy to the server.

Thanks
Senthil S

Tuesday, March 29, 2011

Adding SPNavigationNode to current navigation programatically in SPWebEventReceiver

When I provision a site using custom site template we may want to customize the Left navigation bar. I wanted to clear out all the navigation and have My own custom static links in newly created site.

As we know we can change the navigation using UI by customizing navigation under Site Settings > Navigation > Navigation Editing and Sorting. But I am trying to do it through programatically and was able to clear out all the navigation. When I try to create a new heading and save to the site navigation, it was failing to save it.

So the trick is to get the Publishing web using PublishingWeb.GetPublishingWeb(SPWeb) before adding the navigation nodes. If you get the PublishingWeb before customizing the navigation everything seems to be working fine.

PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
publishingWeb.Navigation.CurrentNavigationNodes.AddAsFirst(new SPNavigationNode("Some Text", properties.ServerRelativeUrl
                                                                                                                                                   + "/Pages/media.aspx", false));
publishingWeb.Update();


And that did the trick to add a new navigation node with the above specified URL once the site is provisioned.

Refer this MSDN article for all sort of properties to modify navigation for a site. (http://msdn.microsoft.com/en-us/library/ee570519.aspx)