Installation and Activation
(Very easy, no coding required)

For those interested in how to install this solution, it is very easy and does not require any coding, compiling, or editing.

Basic Install Steps:

Note: This command must be executed on the (only one) SharePoint web server, and you must be a local administrator.

Add the solution using the STSADM command: stsadm -o addsolution -filename path\VASCSiteAction.wsp
Deploy the solution using the STSADM command: stsadm -o deploysolution -name VASCSiteAction.wsp -allowgacdeployment -immediate -allcontenturls
Optional - to restart IIS: iisreset /noforce
Using (Activating) the new feature:

Navigate to the site you want to hide the View All Site Content link.
Go to the Site Settings for that site (Site Actions > Site Settings).
Click the Site Features (not the Site Collection Features) link under the Site Administration section.
Activate the new feature named "Hide the View All Site Content link".
Your View All Site Content link should now be hidden and the View All Site Content link should now appear in the Site Actions menu.

For those only interested in using this solution, you do not need to read any further. However, for those who are interested in how this is accomplished, the rest of this article discusses just that.


So, How'd You Do That?

Update

This solution can also be used to hide the Recycle Bin. Simply add the following code to the custom core.css file in the sample solution project and your Recycle Bin will also be hidden.

#ctl00PlaceHolderLeftNavBaridNavLinkRecycleBin
{
Visibility:hidden;
}

Overview
Windows SharePoint Services (WSS) 3.0 has provided a tremendous leap forward from WSS 2.0 in securing and dynamically rendering links to the user based on their access. This much needed improvement is also applied to the View All Site Content link in SharePoint 3.0. The View All Site Content link will only be rendered to users who have at least a minimum level of access to a given site such as adding items to any list or document library on the site. For sites that allow anonymous access users to have only read access, this View All Site Content link will not appear. However, there are times when a user’s level of access causes the View All Site Content link to appear, even when the site designers or administrators would rather not volunteer this link so freely to the user. For this reason it is sometimes desired to have this link removed from the page for all users except maybe for site administrators or designers. This is when the old adage of “Out of sight, out of mind” is an option site administrators would like to have.

The result of this article is to hide View All Site Content link from the users. An additional View All Site Content menu item is added to the Site Action menu and is accessible only to users having the AddAndCustomizePages right.

Here is a picture of the typical View All Site Content link as it appears on a SharePoint web site and how it looks after it is hidden.

Before (Normal) After (Hidden)



Additionally I add a new custom menu item to the Site Action menu. Here is the result of the new link. This link will only appear for users having the AddAndCustomizePages right such as designers and administrators.



And finally, this functionality is wrapped up into feature allowing it to be activated or deactivated for each site as needed. Here is the new feature that will appear in the list of Site Features for a web site.



All of this is wrapped in to a single SharePoint solution package (.wsp) file and can easily be installed on a SharePoint farm by a server administrator.

Note: From this point forward in the document, any reference to the View All Site Content link will be abbreviated to VASC.

Consideration

There are a couple ways to in which to accomplish this. The first and most obvious method is to modify the master page that contains this link. This involves a fairly simple process of modifying the master page and removing the VASC link, then redeploying the new master page. The drawback from this is that you do have to modify the master page which is sometime not desirable, plus the master page is likely to have more than one site based on it, and it may be desirable to have this View All Site Content link remain on those sites.

However, if you are willing to modify the master page, there is another posting you may find of value. Keep in mind the security you define in the master page will be the same for all sites on your SharePoint farm. If that is desirable, you may find this post on SPSecurityTrimmedControl: Conditionally display contents by security of use.

My Approach

I had a couple goals I wanted to my solution to meet. They were:

1. To be able to selectively choose the sites where the VASC link is hidden.

2. Avoid having to modify the master page if possible.

3. Provide a simple way for users to hide/remove the VASC link.

After a little investigation, a few things about SharePoint (3.0/2007) surfaced that allowed me to achieve all of my goals and provide a solution that can easily be implemented.

Hidden by Style

The approach I have decided to use is to simply hide the VASC link using a style sheet modification. The VASC link for most, if not all of the sites assigns an ID (ctl00PlaceHolderLeftNavBaridNavLinkViewAll) to the anchor tag containing the VASC link. This makes it easy pretty darn easy hide this link by simply adding a bit of style code to the page. In fact, just for giggles, you can copy the following style sheet code into a Content Editor Web Part. This web part can even be strategically placed at the bottom of the page; optionally hide the title bar and nobody would even know it was there. Here is the sample style to try it just for fun. This will hide the View All Site Content link on your page.

#ctl00PlaceHolderLeftNavBaridNavLinkViewAll
{
Visibility:hidden;
}

But this is not really good enough. At least, not alone this isn’t.

I needed a way to do this for every page on a given site. And copying this code to each and every page on a site is not only extremely tedious; it is almost guaranteed to be incomplete and error prone. Microsoft Office SharePoint Server (MOSS) 2007 does provide an easy way to do this, but Windows SharePoint Services (WSS) 3.0 does not. Using MOSS 2007, you can apply a custom style sheet to a web site and optionally apply it to every sub site. For SharePoint servers where this is desired, and if you are using MOSS 2007, this will work for you. Also keep in mind; you just removed the VASC link for every user – including your site designers and administrators. Although this is not the worst of all problems, it is probably not the absolute desired solution either.

I still like the idea of using the custom style code to hide my VASC link. But I also need to place a link on the page for users who will need easy access to the VASC link such as designers and administrators. I know I can easily accomplish this by adding an access controlled link to the Site Actions menu, but I will come back to this in a moment. I still need to address how to easily apply a customized style to every page on a given site.

CustomizeCss

So how can I apply a custom style to every page on a given site? SharePoint provides a way to do this using the SharePoint object model. With a bit of custom C# code I use the SPWeb.CustomizeCss method to specify a custom style sheet to be used on every page of my site.

The CustomizeCss method on the SPWeb class provides way to specify the style sheet file name of an existing style sheet used by SharePoint. SharePoint utilizes a number of different style sheet files. The one we are interested in is the style sheet file that is applied to each and every page on the site. One such style file is the core.css file, and this will do just for our needs. The standard default core.css file is located in …\12\TEMPLATE\LAYOUTS\1033\STYLES. This STYLES folder is a virtually mapped via the /layouts virtual directory that is mapped to each and every site in SharePoint. So, the core.css file is accessible to every site by simply using the URL of “site-root-url/layouts/1033/styles/core.css”. For every page that SharePoint renders, it renders a link to the core.css using this path.

However, for any site that has been configured to use a custom core.css style sheet via the CustomizeCss method on the SPWeb class, the URL rendered in each page references a core.css file located in a different location. This is accomplished in C# by the following code where web is an instance of the SPWeb class for the web site of your choice.

web.CustomizeCss(“core.css”);
web.Update();

The CustomizeCss(“core.css”) statement tells SharePoint to use a custom copy of the SharePoint core.css file. Once this CustomizeCss method is executed, a copy of the core.css file found in the …\12\TEMPLATE\LAYOUTS\1033\STYLES folder is copied to the folder (not a document library) named _styles on the applied site. The resulting URL to this new core.css file can be found at
site-root-url/_styles/core.css”. Modifying this core.css file will affect only the current site.

Reverting this site back to using the original global (un-customized) copy of the core.css file can be accomplished just a easy using the following code.

web.RevertCss(“core.css”);
web.Update();

Executing the RevertCss method does not remove the custom core.css file on the web site’s “/styles” folder. It simply tells the site to no longer use it and to use the original core.css found in the C:\…\12\TEMPLATE\LAYOUTS\1033\STYLES folder; which is the same folder as the as the “site-root-url/layouts/1033/styles” folder.

So we now know how to use the CustomizeCss and the RevertCss methods on the SPWeb class provide an easy way to point the site to a new custom style sheet file. Now that we have an easy way to point our site to a custom core.css file, all we need to do is copy our custom core.css file that contains all the original core.css contents plus the extra style code to hide the VASC link and copy it into the _styles folder of the site. All of this can easily be implemented using a SharePoint feature. Using a feature provides a standard way to enable or disable functionality with a site in a safe and secure manner. I won’t cover all the details on how to create the feature here, but the source code provides all the code you need.

Now that we know how to hide the View All Site Content link easily using a feature and the CustomizeCss and RevertCss methods, we need to provide an easy way to allow site designers and administrators to quickly and easily use the View All Site Content link.

Site Action Link

To provide web managers such as designers and administrators with a convenient link equal to the View All Site Content link, we will add a new custom action menu item. I won’t go into the details of the code and how to create the feature here, but I will briefly cover the expected functionality. Again, the source code is available for those interested in the technical details.

The Site Action is usually located in the upper right corner of the web site and contains links used by site administrators such as the Site Settings link. The nice thing about the Site Actions menu is that it is collapse and consumes a minimal amount of screen real estate. So, adding an additional menu option to the Site Actions menu will not only be convenient for site administrators, it’s pretty easy to implement in a SharePoint feature. This new View All Site Content link on the Site Action can be secured in a manner that best suits your needs. In the solution sample I provide, this new View All Site Content link on the Site Actions menu is only visible to users who have the “AddAndCustomizePages” right which allows designers and administrators to see it, but is not visible to typical users of a site.

There are plenty of examples on how to add a custom item to the Site Action menu so I will not cover that in any detail here, but the solution sample I provide does include all the code – and the nice thing is, it isn’t much code.

Installation and Activation

Basic Install Steps:
1 - Add the solution using the STSADM command: stsadm -o addsolution -filename path\VASCSiteAction.wsp
2 - Deploy the solution using the STSADM command: stsadm -o deploysolution -name VASCSiteAction,wsp -allowgacdeployment -immediate -allcontenturls
3 - Optional - to restart IIS: iisreset /noforce

Activating the new feature:
1 - Navigate to the site you want to hide the View All Site Content link.
2 - Go to the Site Settings for that site (Site Actions > Site Settings).
3 - Click the Site Features (not the Site Collection Features) link under the Site Administration section.
4 - Activate the new feature named "Hide the View All Site Content link".

Your View All Site Content link should now be hidden and the View All Site Content link should now appear in the Site Actions menu.

Conclusion

The result is a single feature that a site administrator can activate and deactivate on any web site to hide and show the standard View All Site Content link in the quick launch navigation. Additionally, it adds a useful new View All Site Content to the Site Actions menu that is visible only to users having the AddAndCustomizePages right on that site.

References:

List and Site Permissions
http://office.microsoft.com/en-us/sharepointtechnology/HA101001491033.aspx#2

Last edited Jan 4, 2010 at 6:29 PM by MarkWagner, version 1

Comments

No comments yet.