Thursday, July 03, 2008

SharePoint 2007 Document Library ContextMenu Hiding

SharePoint 2007 Document Library ContextMenu Hiding

First locate yourself to the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033 fine the core.js. From where the context menu item script runs for SharePoint 2007 Document Library.

Lets hide the "Download A Copy" menu under the "Send To" Context menu. Open the core.js file in best .js file editor. And search for the function function AddSendSubMenu(m,ctx).
Where you can see

menuOption=CAMOpt(sm, L_DownloadACopy_Text, strAction, "");
menuOption.id="ID_DownloadACopy";

these lines of code which will display text "Download A Copy" and call the menu operation, just comment those lines and save.

This is the simple way to hide the contextmenu item in the document library.


4 comments:

Madhur said...

This will affect all document libraries.
How to do it for particular document library ?

Keviv said...

Hi

One way is you need to change the master page. Open the SharePoint site using the SharePoint Designer and go to the default master which is used in the document library you need to modify. Do another copy the master page and
SharePoint:ScriptLink language="javascript" name="core.js" Defer="true" runat="server"
And change the core.js to your customizeds core.js and save it.

And now open your document library in SharePoint designer and change the default master page to your custom master page
here
Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"

Hope this helps

Jaime said...

Do you know that if you change this file you will lost Microsoft support for Sharepoint???

Keviv said...

Jaime

You mean to say core.js file?
Is it? Interesting!
Then what is the better solution ?

ASP.NET MVC - Sport Facility Booking system

  The project relies on some external service providers. Thus accessing them via their API requires authentication. An API Key need to be su...