SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
if ( (node.Properties["NodeType"] != null && node.Properties["NodeType"].ToString() =="Area" && pubWeb.Navigation.GlobalIncludeSubSites)
  || (node.Properties["NodeType"] != null && node.Properties["NodeType"].ToString() == "Page" && pubWeb.Navigation.GlobalIncludePages) 
  || (node.Properties["NodeType"] == null))
{ //display here }

Try the above logic on whether or not to hide the navigation node. Substitute Global with Current. I fixed mine for the Global navigation.

Here is a link to more information about the property

share|improve this 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

Your Answer


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.