Showing posts with label Design. Show all posts
Showing posts with label Design. Show all posts

Tuesday, March 24, 2009

Hiding the "View All Site Content" and "Recycle Bin" links in SharePoint

In my experience, there has been more than one client requesting/requiring I hide the "View All Site Content" and "Recycle Bin" links on the out-of-the-box (OOTB) SharePoint Quick Launch navigation normally located on the left hand side of the rendered page. Why? Evidentially, giving users with low-level privileges to edit pages and lists items should not always dictate they have the same access rights to view all site content. Okay, so be it. So what are our options?

Well, there is more than one way to skin a cat — er, SharePoint.

As with a lot of different solutions for SharePoint, there are several approaches one could take to successfully accomplish this — some cleaner than others — and it is also dependent upon whether or not you are working with WSS 3.0 or MOSS 2007.

To get a better understanding, lets look at the code pertaining to the VASC and RB links on the default master page:

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<h3 class="ms-standardheader">
<label class="ms-hidden">
<SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,quiklnch_pagetitle%>" EncodeMethod="HtmlEncode"/>
</label>
<SharePoint:SPSecurityTrimmedControl runat="server" PermissionsString="ViewFormPages">
<div class="ms-quicklaunchheader">
<SharePoint:SPLinkButton id="idNavLinkViewAll" runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx"
Text="<%$Resources:wss,quiklnch_allcontent%>" AccessKey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
</div>
</SharePoint:SPSecurityTrimmedControl>
</h3>
<table class="ms-recyclebin" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td nowrap>
<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/recyclebin.aspx"
id="idNavLinkRecycleBin" ImageUrl="/_layouts/images/recycbin.gif"
Text="<%$Resources:wss,StsDefault_RecycleBin%>" PermissionsString="DeleteListItems"/>
</td>
</tr>
</table>
</td>
</tr>
</table>

As you may already see, there are a few ways we may be able to approach this. One method would be to hide the links using CSS.

Some have suggested to use the following CSS.

#ctl00_PlaceHolderLeftNavBar_idNavLinkViewAll
{
visibility:hidden;
display:none;
}

#ctl00_PlaceHolderLeftNavBar_idNavLinkRecycleBin
{
visibility:hidden;
display:none;
}

The problem with this is you are left with a blank space where the VASC and RB once were. A better way I found which collapses the space is to use the following:

/* hides VIEW ALL SITE CONTENT */
h3.ms-standardheader {
visibility: hidden;
display:none;
}
/* hides RECYCLE BIN */
table table.ms-recyclebin {
visibility: hidden;
display:none;
}

This CSS code can be added to one of two places. If you're not dealing with MOSS, or you have not enabled the Publishing feature in MOSS then the down and dirty way would be to modify the core.css file in the 12 Hive. It is found here:
12\TEMPLATE\LAYOUTS\1033\STYLES\CORE.CSS

While this is a fast and simple way to hide the link it isn't best practices to modify core.css and isn't supported by Microsoft. Also, if you ever install any future updates/releases/hotfixes from Microsoft you are risking having your work overwritten by the Microsoft installation.

I personally like to follow best practices supported by Microsoft, have ways to back out of my customizations, and never risk my stuff gets overwritten by any future updates or installations to SharePoint. Having said all of this, I am left with a few more options.

If you are working with MOSS 2007 and you have the Publishing feature enabled you can set an alternate CSS file and add your custom CSS there. This file can be created in SharePoint Designer and saved to the Styles Library (more on that topic another day), or the file can be added to the 12 hive via xcopy or through a feature. In either case, once the CSS was written it would be applied through the SharePoint UI by browsing to Site Actions > Site Settings > Modify All Site Settings, and under the Look and Feel heading click on Master Page Settings. All the way at the bottom of the page is a section to select an alternate CSS file. Click apply and you're done.

Another option would be to check out Mark Wagner's solution and blog post here:
http://www.crsw.com/mark/Lists/Posts/Post.aspx?ID=36

His article covers and provides a solution (WSP) with more information on 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. Instead, an additional "View all site content" menu item is added to the Site Action menu and is accessible only to users having the AddAndCustomizePages access rights.



This is a nice feature when dealing with WSS 3.0 or collaboration sites which don't have the publishing feature enabled, because by that link is already there on Publishing enabled sites. Because it is a feature, you can activate or deactivate it for each site as needed. Here is the new feature that will appear in the list of Site Features for a web site.



Even though this may fulfill technical and business requirements for hiding the link I don't like the fact that you are left with an empty row at the top of Quick Launch.

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



After



Now you are left with having to do some custom work to your master page to remove the table row, and that was probably not what you were looking to do when you signed up for a packaged solution. If you cannot change your master page then try my suggested CSS above. If you are looking for a packaged fix the I guess Mark's solution is the right one for you and you're done. BUT, if editing the master page is an option, read on.

One of the best additions to WSS 3.0 and MOSS is something called security trimming. This new enhancement is leveraged all over the place in SharePoint. What's more, you can leverage it to solve the issues around the "View all site content" and Recycle Bin" links. By changing the PermissionsString property value in the SharePoint:SPSecurityTrimmedControl tag, you can control the level of visiblility for the VASC and RB links to users with different permissions. Here are some of the different values that can be set:

ViewFormPages: View forms, views, and application pages, and enumerate lists. This is the default value used in SharePoint.

BrowseDirectories: Enumerate files and folders in a Web site using Microsoft Office SharePoint Designer 2007 and WebDAV interfaces.

ManageWeb: Grant the ability to perform all administration tasks for the Web site as well as manage content. Activate, deactivate, or edit properties of Web site scoped Features through the object model or through the user interface (UI). When granted on the root Web site of a site collection, activate, deactivate, or edit properties of site collection scoped Features through the object model. To browse to the Site Collection Features page and activate or deactivate site collection scoped Features through the UI, you must be a site collection administrator.

AddAndCustomizePages: Add, change, or delete HTML pages or Web Part Pages, and edit the Web site using a Windows SharePoint Services–compatible editor.
DeleteListItems: Delete items from a list, documents from a document library, and Web discussion comments in documents.

NOTE: The "BrowseDirectories" permission is common to both the "Members" and "Owners" group permission levels, but is not set for the "Limited Access" (anonymous users) permission level. See a complete list of the SPBasePermissions Enumeration here:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx

Well, there you have it. If you've found other methods that work just as well or better, I'd love to hear them.

Saturday, July 5, 2008

Microsoft SharePoint and Cascading Style Sheets Primer

This isn't going to be another post about how cool style sheets are, or even how cool CSS for SharePoint is. No. This is a primer to help you to leverage cascading style sheets in SharePoint. But first, lets begin with telling you about how CSS is used in SharePoint before we get into how to work with it.

There are several CSS files that are used in various ways with SharePoint out of the box. Depending on which page you are viewing and what elements are on the page will result in different style sheets being added to the head of the page. Having said that, there is one global file that is called universally in every page of SharePoint, WSS and MOSS 2007 alike, and it is a beast of a style sheet. Yes, some of you know what I am talking about. It is CORE.CSS. How big is it? How does almost 4400 lines suit you?

The reason "Core" (as it is typically referred to) is so large is because it contains all of the global classes that are used in SharePoint for everything including the top navigation and flyout menus, the quicklaunch menu, the global links (My Links, My Sites, and Welcome "username"), and web part styling to name a few.

In addition to Core, there are also other style sheets which are very important such as CALENDAR.CSS (for the calendar of coarse) and datepicker.css (mini datepicker calendar used in some list items and the clendar list page). But where are these files? It's default location is usually installed in the STYLES folder, locate in:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\STYLES\

All of the CSS files used in SharePoint are found in that location and are listed as follows:
CALENDAR.CSS
CONTROLS.CSS
CORE.CSS
datepicker.css
EwrDefault.css
HELP.CSS
HtmlEditorCustomStyles.css
HtmlEditorTableFormats.css
MENU.CSS
OWSNOCR.CSS
PORTAL.CSS
RCA.CSS
SiteManagerCustomStyles.css


Some have even suggested to use the default CSS files as a starting point for manipulating the default styling for SharePoint by saving your own copy of them to use as the basis for creating an overriding style sheet, but this can be extremely overwhelming of a task if you are new to SharePoint styling. If you are a seasoned veteran with SharePoint and won't get intimidated by all of that code then by all means, dive in. In the future I will provide a master overrides file to start off with which will contain all of the default classes and OTB (out of the box) SharePoint styling for you to play with. That was how I started out learning. But if you want to take the path of least resistance then there is are alternatives.

Surely the simplest thing would be to crack open SharePoint Designer. Designer gives you the ability to open up the master page and select elements in a WYSIWYG manner to apply styling to the site. Upon altering styles it will automatically create an alternative styles sheet and link it to the maser page where you can see your changes instantly. You can reference your own images for backgrounds and alter fonts, colors, sizes, and positions until your hearts content. But Designer is not a tool that should be approached lightly and without some forethought regarding it's effect on the SharePoint environment. It would be helpful to first educate yourself of the advantages and disadvantages of "customizing" SharePoint. I'll cover this topic in future articles. For now, lets move on to the other alternatives.

You can also create your own overriding CSS file from scratch and which you can apply to publishing sites in MOSS 2007, link directly in the head of the master page, or call though the page layout. Heather Solomon has created an amazing CSS Reference Chart that maps out a ton of the classes SharePoint uses. view the source code rendered in the page through the browser and walk the DOM, latching onto classes and IDs until you get the desired effect you are looking for.

There is two more alternatives, both of which relate to themes. Some of you may be familiar with SharePoint having a set of themes provided to you OTB but may not know how can you leverage this. One way would be to create your own theme (I'll cover this in another article in the future and link to it here). Another alternative would be to use the two CSS files that already reside in a theme folder as a starting point. Conveniently, Microsoft has done the dirty work for us and came up with these themes which already manipulate the styling on pages, lists, and the application portions of SharePoint alike. Cool, right? But where are the themes locate? Try looking here:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES\

If you open up any of the provided theme folders you will see two CSS file files: theme.css and mossExtension.css. The mossExtention.css is there to control MOSS 2007 specific classes that may not be needed in WSS. In any regard, I suggest you pick a theme that is as close as possible in styling as the result you are trying to achieve, open up both of CSS files in the theme folder, and copy everything into your own custom CSS file.

I hope this give you a good starting point and a head start. Check back in the future where I'll go into more details about stying for SharePoint.