Welcome to MSDN Blogs Sign in | Join | Help

Pranab Paul's Blog - Development Tips on SharePoint, Office and Web

------------------------------------------Web Parts, Workflow, InfoPath Form Services, Features, Site Definition, Event Receivers, Excel Services, Business Data Catalog (BDC), Search

News

SharePoint 2007 (MOSS/WSS) - how to remove "Download a Copy" context menu from a Document Library

One of my friend and colleague asked me this question. I found it tricky and a good post for my blog. Here is what you have to do:

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.

Posted: Saturday, December 06, 2008 12:57 AM by pranab

Comments

~ YESChandana ~ said:

Hot links - 1st Week of December 2008

# December 7, 2008 9:59 PM

Varun said:

Hey pranab.. Nice article...but i need smthing more. i need to implement audience targeting in context menus...

I need different users to view different items in the context menu depending on the permissions they have. Can u please tell me if it is possible...

# December 8, 2008 4:59 AM

Mirrored Blogs said:

Esta es una nueva serie de recopilacion de articulos interesantes sobre la plataforma, donde tratare

# December 9, 2008 12:52 AM

Dailycode.net said:

Remove send TO from the item menu

# January 19, 2009 8:11 AM

Mark Deraeve said:

Thanks for the info,

it helped me very much.

I changed the core.js and added an IF to check for the list name.

Linked to this article in my blog post:

http://www.dailycode.net/blog/post/Remove-send-TO-from-the-item-menu.aspx

# January 19, 2009 8:14 AM

jo said:

What happens if the core.js is erase due to a Sharepoint pack !!??

# January 30, 2009 10:58 AM

Emir said:

God question Jo.

This is not supported way to modified context menu.

# March 24, 2009 5:16 PM

Mark Deraeve said:

You should carefully control all the unsupported changes made to your SharePoint installation. When installing a pack, you should check these changes always. It is not always possible to change SharePoint the way you like in a supported way, yet is is the best way to make changes obviously.

# April 23, 2009 1:33 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker