Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am accessing the quick launch nodes programmatically by using

SPWeb currWeb = SPContext.Current.Web;
SPNavigationNodeCollection nodes = currWeb.Navigation.QuickLaunch;
foreach (SPNavigationNode node in nodes)
{
   ...
}

Strange thing is that there are more nodes in the collection than i see in SharePoint in the quick launch! The extra nodes that are in the collection are the different sub webs.

But i only want to use the "real" elements that are in the quick launch. How can i access them?

It is since i turned on the publishing features i have this issue. And using

if (PublishingWeb.IsPublishingWeb(currWeb)) { 
   PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(currWeb); 
   nodes = pubWeb.Navigation.CurrentNavigationNodes; 
} 

to get the nodes gives the same results.

share|improve this question
add comment

1 Answer

I believe this is normal behavior to facilitate the "display subsites" option in the navigation. You'll likely need to do some additional logic on each node to determine if it's a subweb or not and display accordingly.

share|improve this answer
    
But if i do that, it will also filter the subwebs that are manually added to the quick launch. I only want those 'hidden' items filtered. –  Davy Jan 28 '13 at 16:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.