Applies To: SharePoint
By default in SharePoint 2010 nearly every visitor to your site automatically gets an “All Site Content” link added to their quick launch. In addition, there’s a “View All Site Content” option in the Site Actions menu. Here’s a default team site as seen by a user with only Read permission:
For team sites and basic work areas this is a great idea. However, there are several cases where it would be better if this wasn’t shown to the average user – for instance, a Business Intelligence Center. A Business Intelligence Center site is where you’re probably hosting PerformancePoint content and/or reports, etc. Anyone using your dashboards must have read permission to all the content and datasources. But generally you don’t want general users browsing this content. It’s better to provide good navigation either through the quicklaunch or a nice home page. However, you want your designers to still have this link.
Fortunately, Microsoft built the quicklaunch link with a ClusteredSPLinkButton and the Site Actions link with a MenuItemTemplate both of which have the PermissionMode and PermissionsString properties. These controls allow you to perform simple permission trimming.
SPSecurityTrimmedControl Permission Trimming
The controls both inherit from SPSecurityTrimmedControl which is where the permission trimming properties and methods come from.
The first property, PermissionsString, defines the permission(s) a user must have in order to view the control. You can find a list of permissions here. By default both of the All Site Content link controls use the ViewFormPages permission (Basically, anyone who can get to the site).
You can use multiple permissions in your PermissionsString by separating them with a comma. How those are used is determined by the PermissionMode property which can have two values: Any or All. When set to “Any” the control will show if a user has at least one of the permissions in your PermissionString. When set to “All” the control will only show if a user has every permission listed in your PermissionString.
We wanted the All Site Content links to only show for users with Full Control over a site. So our PermissionsString needs to be ManageWeb, and since we’re only using one permission our PermissionMode can be either Any or All or even not included.
Hiding the Quicklaunch Link
To change the permission trimming attributes for our controls, we have to edit the MasterPage. If you’re developing a custom branding solution then this should be easy enough to do directly in Visual Studio. If you’re just customizing on the fly, then you’ll use SharePoint Designer (Choose Edit in SharePoint Designer from the Site Actions menu).
In the default master page (v4.master) the Quicklaunch All Site Content link can be found around line 573 and is included in the PlaceHolderQuickLaunchBottomV4 UIVersionedContent control. Here’s what it looks like by default:
<SharePoint:ClusteredSPLinkButton id="idNavLinkViewAllV4" runat="server" PermissionsString="ViewFormPages" NavigateUrl="~site/_layouts/viewlsts.aspx" ImageClass="s4-specialNavIcon" ImageUrl="/_layouts/images/fgimg.png" ImageWidth=16 ImageHeight=16 OffsetX=0 OffsetY=0 Text="<%$Resources:wss,quiklnch_allcontent_short%>" accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
So all we have to do is change line 576 to read PermissionsString=”ManageWeb” and save.
Hiding the Site Actions Link
The Site Actions menu is just as easy to edit. The View All Site Content link can be found around line 137 inside the SiteActions FeatureMenuTemplate control. Here’s what it looks like by default:
<SharePoint:MenuItemTemplate runat="server" id="MenuItem_ViewAllSiteContents" Text="<%$Resources:wss,quiklnch_allcontent%>" Description="<%$Resources:wss,siteactions_allcontentdescription%>" ImageUrl="/_layouts/images/allcontent32.png" MenuGroupId="300" Sequence="302" UseShortId="true" ClientOnClickNavigateUrl="~site/_layouts/viewlsts.aspx" PermissionsString="ViewFormPages" PermissionMode="Any" />
Again, just change line 145 to PermissionsString=”ManageWeb” and save.
That’s it! Here’s what the same Team Site now looks like to a user with Read permission:
11 thoughts on “Hide “All Site Content” Link Based on Permission”
[…] https://thechriskent.com/2012/09/07/hide-all-site-content-link-based-on-permission/ […]
[…] Took out All Site Content link and all other navigation was on homepage of site. Sub sites had tab links to parent site. […]
Thanks Chris! Works like a charm!
Hi I have tried this and it does not seem to make a difference, I only changed the viewformpages to ManageWeb, any idea why it would not work for me?
For whatever reason, it didn’t work for me either. SharePoint 2010 standard. Tried to hide the ViewAllSiteContent link. No help. I’m sure I have the right masterpage and checked it in etc.
Awesome. Finally an example that I could follow and get all the areas.
THANK YOU!!!!!! Just what I was looking for! And agree with previous poster. Great example I could easily follow and implement.
Posts fade into oblivion pretty quickly but nevertheless would like to know if any of those for whom this did *not* work ever resolved. And if so, did it have anything to do with whether the Publishing feature was activated for the site in question? Thanks.
Didn’t hide Site Contents link for users with Read permission for me. Anybody else find an alternate work around?
This did not work for me. While the directions were straightforward and easy to follow, I did not get the results I was hoping for. My ultimate goal would be to not show the bottom left nav at all to anyone. No box on the left that has a recycle bin and All Site Content, and no site actions button at the top. I would think in 2014 this would be such an easy solution.