Managed to get desired results with removing all pages and subsites from navigation.
web.AllProperties["__CurrentNavigationIncludeTypes"] = 0;
Still the cause of this mysterious functionality still remains.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to remove a link to the publishing page created by the PNP provisioning template. Link is visible in the site's navigation but when trying to delete it with CSOM code the link is not included in Navigation.Quicklaunch
.
I have also tested powershell:
$web = Get-SPWeb mysitesurl
$web.Navigation.QuickLaunch
The link cannot be found in this way either.
Link can be manually hided from the navigation with editing the left navigation or from the address _layouts/15/AreaNavigationSettings.aspx
If I edit left navigation from the UI my missing link is then accessible through code and powershell. Any ideas why this is happening and how it can be fixed programmatically?
Managed to get desired results with removing all pages and subsites from navigation.
web.AllProperties["__CurrentNavigationIncludeTypes"] = 0;
Still the cause of this mysterious functionality still remains.
My test code for your reference,it works well in my environment:
using (ClientContext clientContext = new ClientContext("http://sp"))
{
NavigationNodeCollection navigationNodes = null;
navigationNodes = clientContext.Web.Navigation.QuickLaunch;
clientContext.Load(navigationNodes);
clientContext.ExecuteQuery();
NavigationNode node = navigationNodes.Where(n => n.Title == "List Title").FirstOrDefault();
if (node != null)
{
node.DeleteObject();
clientContext.ExecuteQuery();
}
}
If you have any update on this issue,please feel free to share with us.
-----------------------------------------
Updated------------------------------------
JavaScript code hide quick launch item:code.txt
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Yes, that's absolutely code that works, but only one page exists on my quicklaunch that cannot be found from the navigationNodes.
That problem might my somehow related how the page is provisioned...
The problematic link has a different icon than others. Is this the reason?