Monday, July 6, 2009

SharePoint Designer 2007 - Hide the Quick Launch Link

Today my manager came up with the requirement that Recycle Bin Link in Quick Launch Menu should be visible to Administrator only.
If it was the case for a webpart then I could easily specify the Target Audience and voila. But unfortunately webpart zone is not available for Quick Launch Menu and I didn’t want to write custom menu just to hide the RecycleBin link so the genius came up with the following dirty trick. (Yes, I have recognized myself as a genius since childhood).

1. Launch the SharePoint Designer.
2. Navigate to _catalogs -> masterpage -> default.master.
3. Create a backup of the master page file and open original for editing.
4. Scroll down till the bottom and paste the following javascript code right before </Body> Tag:

var UserID = document.getElementById('zz8_Menu').innerHTML;
UserID = UserID.split('<')[0]; UserID = UserID.split('\\')[1]; if (UserID != 'Administrator') { //Hide Recyclebin var objRecycleBin = document.getElementById('ctl00_PlaceHolderLeftNavBar_idNavLinkRecycleBin'); if (objRecycleBin) { = 'none'; } }

5. Save and it should hide Recyclebin for all users except for the administrator.

Note: Please check for the Ids ctl00_PlaceHolderLeftNavBar_idNavLinkRecycleBin and zz8_Menu by view source.

Official SharePoint Documentation

I have recently contributed to the official SharePoint documentation for developement. Check it out here: