SharePoint 2007 (MOSS) – How to remove "Download a Copy" context menu from a Document Library

Go to your 12 hive\TEMPLATE\LAYOUTS\1033 folder. Open up the Core.js file. Find the function AddSendSubMenu. Go to the last 3 lines:

strAction = "STSNavigate(‘" + ctx.HttpRoot + "/_layouts/download.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "&FldUrl=" + escapeProperly(ctx.SendToLocationUrl) + "’)"; ;

menuOption = CAMOpt(sm, L_DownloadACopy_Text, strAction, "");

menuOption.id = "ID_DownloadACopy";

Now if you want to remove "Download a Copy" option from all the document libraries then comment all three lines.

If you want to remove it for some custom List Definition that you have created you may do like:

if(ctx.listTemplate !=10001)

{

strAction = "STSNavigate(‘" + ctx.HttpRoot + "/_layouts/download.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "&FldUrl=" + escapeProperly(ctx.SendToLocationUrl) + "’)"; ;

menuOption = CAMOpt(sm, L_DownloadACopy_Text, strAction, "");

menuOption.id = "ID_DownloadACopy";

}

Where 10001 was your custom list template id.

If you want to do it for a specific Document Library then you would do like this:

if(ctx.listName !="{28958B49-8C76-4987-815C-CF5A107FF522}")

{

strAction = "STSNavigate(‘" + ctx.HttpRoot + "/_layouts/download.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "&FldUrl=" + escapeProperly(ctx.SendToLocationUrl) + "’)"; ;

menuOption = CAMOpt(sm, L_DownloadACopy_Text, strAction, "");

menuOption.id = "ID_DownloadACopy";

}

As you can see you have to pass the list GUID as listName.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s