in SharePoint, SharePoint 2007

SharePoint – Hiding Menu Items from the Edit Control Block

If you want to add a menu item to the Edit Control Block(ECB) in SharePoint, you can do so by writing a new Feature. But if you want to hide some of the  menu items, you cannot do so by writing a Feature. SharePoint uses its JavaScript file – core.js to render the ECB. MSDN has an excellent article explaining how to remove menu items from ECB.

So, I went ahead and did the changes by adding a new file called customcore.js and included the same in my Master page. I removed the Send To menu item in the JavaScript code. But the change was not reflecting and the ECB still had the Send To option. I checked my code several times and I was sure I had removed the Send To code in the JavaScript, but why is it showing still? I went back to the MSDN article and verified each step:

  • Copy the core.js file from its default location at <%Program files %>common filesMicrosoft sharedweb server extensions12Templatelayouts1033, place it in the same folder, and rename as customcore.js file.
  • Make the necessary changes in the customcore.js file by removing unwanted ECB menu items.
  • To create the custom master page, make a copy of the default.master page and rename it as custom.master.
  • In the custom master page, add the following line to render the customcore.js file:

<SharePoint:ScriptLink language=”javascript” name=”core.js” Defer=”true” runat=”server”/>
<SharePoint:ScriptLink language=”javascript” name=”customcore.js” Defer=”true” runat=”server”/>

Save the custom.master page and upload it to the master pages gallery of the site. Then apply the custom.master page as the default master page for the site.

Everything was there! Hold on! –  In the 4th step we can see that even though we have our own customcore.js , we still need to add core.js! And that was the ‘thing’ I had missed.

I was under the impression that since my customcore.js is just a copy of core.js, it is enough if we included customcore.js in our master page. But SharePoint doesn’t like that way. We have to render core.js no matter what and then include our own customcore.js. If you don’t do so, then SharePoint will load the default core.js, ignore the customcore.js and you will lose your changes!

So, do not forget the 4th step whenever you hide menu items from the ECB 🙂

Write a Comment

Comment

Time limit is exhausted. Please reload the CAPTCHA.