views:

207

answers:

1

I have written a feature(Site scoped) that adds custom menu items to the New Menu. it will create new documents inside the document library.

Below are the sample entries in Feature and Element manifest file

<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="59bba8e7-0cfc-46e3-9285-4597f8085e76" Title="My Custom Menus" Scope="Site" xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
<ElementManifests>
<ElementManifest Location="Elements.xml" />
</ElementManifests>
</Feature>

and Elements.xml file is

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
<CustomAction Id="NewMenu1" GroupId="NewMenu" RegistrationType="List" RegistrationId="101" Location="Microsoft.SharePoint.StandardMenu" Sequence="1002" ImageUrl ="/_layouts/images/DOC32.GIF" Title="My New Menu" Rights="AddListItems,EditListItems">
<UrlAction Url="javascript:var surl='{SiteUrl}'; window.location='/test/mypage.aspx?siteurl='+surl+'&amp;listid={ListId}&amp;Source='+window.location" />
</CustomAction>
</Elements>

By the above sample. My New menu is listed in all document library. This new menu is creating a new document under document library. But i have to hide this in some document library. Is this possible? Please suggest me.

+1  A: 

You can hide menu items like this by adding some javascript to a content editor web part. The content editor web part should be put on your page where you want the menu item to be hidden

An example using jQuery is as follows:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;

<script type="text/javascript">

$(document).ready(function(){ 
   $("ie\\:menuitem[text='My New Menu']").each(function(){
       this.hidden=true;
   });
});

</script>

HTH

Paul Lucas
Thank you Paul, but we couldn't ask the customer to create content editor web part or add the script in the content editor web part. Is there is any other solution
barathan
You could make your feature 'Web' scoped. And then only activate it on webs that require the custom menu item. Document libraries that do not need the custom menu would need to be in a web that does not have the feature activated.
Paul Lucas
Yes you are right Paul, but this fails in one use case. I have to show my new menu in document library sub folder not in root folder. In this case it will fails
barathan
Ok which solution are you talking about, the jQuery or feature activation one above?
Paul Lucas