Fix: SharePoint 2010 Left Navigation(QuickLaunch) Items that are not visible

Hi,

If you have a problem that you can not access or see any object programmatically in your code or powershell script you might be able to go around this problem. In my case annoyingly SharePoint showed navigational items in the Quick Launch UI management page(items like sites) BUT once I tried to access items through code and hide them I could not see any items at all.

What I did was to re-activate the site level SharePoint out of the box publishing feature that enables publishing functionalities. After this SP did some “magic” behind the scenes and I was able once again to access navigational items and hide them using the ExcludeFromNavigation publishing method.

WARNING: Before you execute the script below OR decide to re-active the OTB Publishing feature take notice that doing so may have unexpected effects in your environment. Test this well before applying to a production environment.

PortalNavigation.ExcludeFromNavigation Method

Below is a sample script that will do what I just described:

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

 

$siteURL = “Your site URL”

 

$spSite = [Microsoft.SharePoint.SPSite] ($siteURL)

 

if($spSite -ne $null)

{

                $web = $spSite.OpenWeb()

                if($web -ne $null)

                {

                                Disable-SPFeature -URL $siteURL -Identity PublishingWeb -Force

                                Enable-SPFeature -URL $siteURL -Identity PublishingWeb

                                if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))

                                {

                                                $spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

                                                if($spPubWeb -ne $null)

                                                {

                                                                foreach($subWeb in $web.Webs)

                                                                {

                                                                                if($subWeb -ne $null)

                                                                                {

                                                                                                $spPubWeb.Navigation.ExcludeFromNavigation($false, $subWeb.ID)

                                                                                                $subWeb.Dispose()

                                                                                }

                                                                }

                                                }

                                }

                                $spPubWeb.Update()

                }

 

   $web.Dispose()

   $spSite.Dispose()

}

else

{

   Echo $siteURL “does not exist, check the site collection url”

}

Echo Finish

 

Resources: SharePoint Navigation

NavBars – If only it was that simple! – CodeProject

Extending the 50-site limit in SharePoint’s Site Directory : slightlyRational

Controlling navigation options from the onet.xml – Vesa “vesku” Juvonen – Site Home – MSDN Blogs

Steve Graegert » Blog Archive » SharePoint Quick Launch Items Disappearing?

SharePoint navigation – SPNavigationNode.IsVisible returns always true – Blog de Stephane Eyskens sur SharePoint

Customizing the Quick Launch menu with SPNavigationNode, SPNavigationNodeCollection and Audiences – Journal – David San Filippo’s Blog – creator of Snip-It Pro, a code snippet manager, and OnceFound sites

Martin Hatch – Blog: Fixed: SPWeb.Navigation.QuickLaunch == null

The SharePoint’s Live for Me (by Jérôme Noirfalise): How to display more than 50 items in SharePoint menu

SharePoint Navigation Providers – Part 1 « Welcome to ShanthaKumar’s Blog

How To: Hide SharePoint 2010 root node from the top menu

Customizing the Navigation Areas