Top Menu

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) { objRecycleBin.style.display = '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.


5 comments:

  1. Hello and thanks for the post,

    Does this solution work for any other site which is added manualy?? ex: if I just add a link in quick launch and want to hide it,
    and is it possile to access the file you have mentioned without SharePoint Desigenr??


    Thanks again

    ReplyDelete
  2. one more question, does it hide the Recyclebin for Users with Administrator UserName or with Aministrator Rights??
    coz there can be more than one administrator for the site!

    ReplyDelete
  3. Post1 (Answer): You have to add this script to the Pages where you want to hide the menu. However, a better way to do this is explained in this post: http://mysplist.blogspot.com/2009/11/security-on-sharepoint-website-controls.html.
    Also, you need SharePoint Designer to make changes to the aspx pages.

    Post2 (Answer): Yes, It does.

    ReplyDelete
  4. Post 2: It hides the user having Administrator name.I know its a bad solution but again, a better solution is here:

    URL: http://mysplist.blogspot.com/2009/11/security-on-sharepoint-website-controls.html.

    ReplyDelete
  5. HI

    You can use this css

    .ms-navframe
    {
    display:none;
    }
    this will work

    ReplyDelete

Official SharePoint Documentation

I have recently contributed to the official SharePoint documentation for developement. Check it out here: https://docs.microsoft.com/en-us...