Looking for a straight forward and relatively easy way of hiding the All Site Content link from the quick launch area?
All you need to do is create a feature, manisfest file and user control that contains the script to hide the link.
The feature should ideally be site or web scoped although it doesn’t really matter and depends where you want the link removed from.
Create a new empty element file and replace with the following content:
<?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Control Id="AdditionalPageHead" ControlSrc="~/_controltemplates/HideAllSiteContent.ascx" Sequence="1" /> </Elements>
All this is doing is adding the user control HideAllSiteContent.asx into the SharePoint placeholder called AdditionalPageHead, so whenever a page is loaded the content of this control will be processed. This technique avoids you having to deploy your own master page with the custom script embedded in the head section of the page and will be used by all pages within the scope of the feature.
The last step in implementing this feature is to create the CONTROLTEMPLATES folder in your solution. How you do this will be slightly different depending on the version of SharePoint you’re developing against and the Visual Studio extensions being used. Basically, you want to end up with a folder called CONTROLTEMPLATES within the TEMPLATE folder.
Now create a user control called HideAllSiteContent within the CONTROLTEMPLATES folder. The content for this control should be edited to look something like:
The first part of this script calls the _spBodyOnLoadFunctionNames.push function that is part of the SharePoint installation. Whenever the body of the page is loaded, the onload event handler executes all functions that have been added to the queue. We’re adding our own function called loadScript to that queue.
The loadScript function checks to see if the jQuery object has been loaded, adding the script tag for it when it does not exist. You’ll notice that a callback method has been added to the script element. The callback method callback() is executed after the script library has been successfully loaded. I’ve linked to Google’s hosted version of this file but you may find it better to deploy a local version and link to this instead.
If the jQuery object was detected, we use the $(document).readymethod to call our callback method on page load instead.
Either way, the callback method will be called as the page loads and it’s here that we hide the All Site Content link from the quick launch area using the jQuery command:
Obviously, this can be used for more than just hiding the All Site Content link.