In SP2013 you have the recent entry in the navigation. Is there an easy way to automatically hide/remove this entry?
9 Answers
Did some additional research and found the answer myself.
var title = SPUtility.GetLocalizedString("$Resources:core,category_Recent", null, web.Language);
SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
foreach (SPNavigationNode node in nodes)
{
if (node.Title.Equals(title))
{
node.Delete();
break;
}
}
-
1Where did you put this code? I put it in a Feature Event Receiver in the FeatureActivated event, & it didn't work :(– MarkusAug 4, 2015 at 15:22
You can manually delete the header from:
Site Settings-> Look and Feel -> Navigation
-
I am creating a webtemplate based on a teamsite. Do you know how this can be done by code?– RemkoMar 7, 2013 at 13:20
-
What is the result you are looking for? Should the navigation be inherited from the parent site? Mar 7, 2013 at 14:22
-
I already found and posted the answer I was looking for. Tnx for helping– RemkoMar 14, 2013 at 9:59
I have an out of the box solution.
- *Settings -> Site contents
- *Site permissions
- *Create Group
- Make a new group with no permissions.
- Delete all users from the group.
- *Settings -> Site contents
- *Navigation
- Select the "Recent" heading
- *Edit
- Set Audience = the group from step 4
- *OK
- *OK
Now only members of a group, with no members, are able to see the "Recent" heading.
With Sharepoint Online (Office 365) you can delete the Recent from the menu by doing the following:
- Select "Edit Links" at the bottom left of menu
- Click "X" next to Recent" to delete it and save
NOTE: You'll need to recreate the menu links under "Recent" if you follow these steps. Under each app you'll need to toggle the on/off radio button for "Display this list on the Quick Launch?" in the General Settings.
In SP13, just go to site settings > Look and Feel > Quick launch and click the recent link. You'll have to put in a url before it will allow you to delete.
The solution I used was to create a SharePoint group (I called mine "RemoveRecent") and have no users assigned to that group.
I then used this PowerShell script to add the "RemoveRecent" group into the "Audience Targeting" section of the "Recent" Quick Launch Navigation Link.
This effectively hides the menu item from everyone.
$Site = Get-SPSite "https://SITECOLLECTION/"
foreach ($Web in $Site.AllWebs)
{
$PublishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$QuickLaunchNav = $PublishingWeb.Navigation.CurrentNavigationNodes
$QuickLaunchHeading = $QuickLaunchNav | where {$_.Title -eq "Recent"}
if ($QuickLaunchHeading)
{
Write-Host $Web.Title "- " -ForegroundColor Green -BackgroundColor Black -NoNewline
$QuickLaunchHeading.Properties["Audience"] = "RemoveRecent"
$QuickLaunchHeading.Update()
}
}
Using jQuery: SharePoint 2013 - Remove Recent
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".ms-core-listMenu-item:contains('Recent')").parent().hide();
});
</script>
- Site Settings -> Quick Launch Select the Edit icon near Recent
- Copy any valid url into the empty URL box (Recent item does not show a URL)
- Click Delete (with an empty URL box, it would have given an error message)
- Confirm deletion
It works in SharePoint 2013, not sure about the earlier versions
I decided as follows: Added the css code on the page that did not want to display the "Recent" menu:
div#zz12_V4QuickLaunchMenu ul#zz13_RootAspMenu li.static span.static span.additional-background{
display:none;
}
-
Never do this, since the IDs get changed mostly between every page refresh and every user. Though they fall in a range like zz12 to zz14....., we may never know May 11, 2018 at 17:36