Waqas Sarwar's profilewaqas's spaceBlogListsGuestbookMore Tools Help

waqas's space

How To: Hide/Remove the View All Site Content link in SharePoint

Article: http://www.crsw.com/mark/Lists/Posts/Post.aspx?ID=36

Summary
This article covers how to hide (remove) the View All Site Content link and/or the Recycle Bin link from the quick launch navigation without having to customize the master page.  Additionally, I cover how I accomplished along with other options, all using the standard functionality provided in Windows SharePoint Services 3.0.

Important:  This solution is not an answer for security.  The user will still have access to the View All Site Content page.  The View All Site Content link is simply removed or hidden from the page.

Applies To

- Windows SharePoint Services 3.0
- Microsoft Office SharePoint Server 2007

Downloads

Hide View All Site Content - Solution Package
Hide View All Site Content - Solution Package and Source Code

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.

  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

Using (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.

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.

#ctl00_PlaceHolderLeftNavBar_idNavLinkRecycleBin
{
       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 (ctl00_PlaceHolderLeftNavBar_idNavLinkViewAll) 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.

#ctl00_PlaceHolderLeftNavBar_idNavLinkViewAll
{
       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:

Enjoy!

Customizing the WSS 3.0/MOSS 2007 Menu Control -- MossMenu source code released

The AspMenu class that ships with WSS 3.0 (and by extension MOSS 2007) is nearly identical in behavior to ASP.NET 2.0’s Menu class (as the name implies). AspMenu derives from Menu and adds tweaks to work around a few reasonably well known annoyances and provides improved highlighting support.

 

Unfortunately, this class was marked sealed and is therefore not eligible to be used as the base class for derived types. Effectively, this means that customers cannot inherit the additional functionality of the AspMenu class when trying to provide further customization of the menu.

 

We realized this problem too late in the release process and were unable to remove the sealed marker from the AspMenu class that ships with WSS. However, we are instead providing the source code for that class here (as an attachment to this blog entry) under the name MossMenu.

 

Note: MossMenu is provided as is and will only work on sites built with WSS 3.0 or MOSS 2007. MossMenu relies on some JavaScript which has been included along with the C# source. This is really just for completeness’ sake [aside: some trival about the use of the apostrophe for the possessive forms of nouns] as this script is automatically included on most pages through the core.js script include reference.

 

Issues with the ASP.NET 2.0 menu, which have been worked around:

1)     If the mouse pointer happens to be hovering over a menu item that exposes a fly-out as the page is loading, it is possible that an error dialog will appear stating: "Internet Explorer cannot open the Internet site, Operation aborted" and a blank page will be shown upon clicking OK. It seems that the problem arises from attempting to append to the DOM before it is properly initialized.

2)     If SSL termination is employed on a site with a menu, users will be greeted with “This page contains both secure and nonsecure items. Do you want to display the nonsecure items?” when hovering over a menu item which exposes fly-outs. (http://support.microsoft.com/?id=910444)

3)     In right-to-left locales, the fly-out indicator arrow still points from left-to-right.

 

Improvements to default highlighting behavior of ASP.NET 2.0 menu:

·         When hooking the menu up to a SiteMapProvider through a SiteMapDataSource, the menu automatically highlights the node that matches that returned by the provider’s CurrentNode property. However, if the particular node returned by CurrentNode is not shown by the menu nothing will be highlighted at all. The improved behavior determines if there is an ancestor of the current node which is displayed in the menu and highlights this node instead.

 

Hope this helps.

 

Chris Richard, Software Design Engineer, WCM Features

Back to Basics: Connecting to Project Server (video)

If you are a project manager who wants to create a project using Project Server 2007, you have two ways of connecting to it. You can connect directly using a Web browser and a URL given to you by an administrator, or you can connect through Project Professional 2007 on your desktop, which is explained explain in this video.

http://office.microsoft.com/en-us/project/HA102910371033.aspx?pid=CH100948801033

Thanks
Waqas Sarwar

Posted by Heather O'Cull at Friday, November 07, 2008 11:09 PM

TechNet Security Resource Center for SharePoint Products and Technologies

Hey Guys!

Just launched today: Security Resource Center for SharePoint Products and Technologies

This page provides IT pros with security resources for Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007. 

image

Thanks
Waqas Sarwar

Special thanks to  chrisfie for this entry at Christophe Fiessinger’s Blog on November 13, 2008, 8:35pm

PM Boot Camp: Up to speed with Project 2007

 
Hi Guys!
 
If you're new to Project 2007, or even new to project management in general, the Up to speed with Project 2007 video series might be the basic training you're looking for. This six-part series covers the basic elements of project management and the Project 2007 interface, as well as how to start a new project, create relationships between tasks, use calendars, build a team, identify project costs, check project progress, and generate reports. The entire series can be viewed in less than an hour, providing a quick way to ramp up and get started managing your projects using Project 2007.
 
Thanks
Waqas
Special thanks to Heather O’Cull this entry at Microsoft Office Project 2007 on November 12, 2008, 6:55pm
 

waqas sarwar

Occupation
Location
Interests
I am certified Microsoft Technical Specilist for MOSS 2007 & WSS 3.0. i like pen friendship.i am live always happy. Donot Worry Be Happy
No list items have been added yet.
 leave a message if you related to this topic i will get back you.Thanks for visiting!
Please wait...
Sorry, the comment you entered is too long. Please shorten it.
You didn't enter anything. Please try again.
Sorry, we can't add your comment right now. Please try again later.
To add a comment, you need permission from your parent. Ask for permission
Your parent has turned off comments.
Sorry, we can't delete your comment right now. Please try again later.
You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
Complete the security check below to finish leaving your comment.
The characters you type in the security check must match the characters in the picture or audio.