SharePoint Feature suggestion

Posted by barathan on Stack Overflow See other posts from Stack Overflow or by barathan
Published on 2010-04-14T13:26:23Z Indexed on 2010/04/15 5:53 UTC
Read the original article Hit count: 338

Filed under:
|

I have written a feature(Site scoped) that adds custom menu items to the New Menu and EditControlBlock of document library. These menu items should show up only when the user has add and edit permissions for that document library. If he selected the menu, url is redirected to my webpart. Webpart is deployed in site collection.

To do this i have two way. I mentioned in as case 1 & case 2. But in the both cases i failed to fulfill my requirement

Below are the sample entries in Feature and Element manifest file

I am passing the current location to sourceurl in order to get the folder url

<?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/">
<ElementManifests>
<ElementManifest Location="Elements.xml" />
</ElementManifests></Feature>

Case 1:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<CustomAction Id="EditMenu1" RegistrationType="FileType" RegistrationId="txt" Location="EditControlBlock" Sequence="106" ImageUrl="/_layouts/images/PPT16.GIF" Title="My Edit Menu" Rights="AddListItems,EditListItems">
<UrlAction Url="javascript:var surl='{SiteUrl}'; window.location='/test/mypage.aspx?siteurl='+surl+'&amp;itemurl={ItemUrl}&amp;itemid={ItemId}&amp;listid={ListId}&amp;Source='+window.location" />
</CustomAction>

<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>

If i use the above code, it was not redirected to site collection instead of it is redirecting to rootsite. Is there is any way to get the site collection variable.

To overcome this issue i used the following code:

Case 2:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="EditMenu1" RegistrationType="FileType" RegistrationId="txt" Location="EditControlBlock" Sequence="106" ImageUrl="/_layouts/images/PPT16.GIF" Title="My Edit Menu" Rights="AddListItems,EditListItems">
<UrlAction Url="~sitecollection/test/mypage.aspx?siteurl={SiteUrl}&amp;itemurl={ItemUrl}&amp;itemid={ItemId}&amp;listid={ListId}&amp;Source=/" />


 </CustomAction>
<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="~sitecollection/test/mypage.aspx?siteurl={SiteUrl}&amp;listid={ListId}&amp;Source=/" />


 </CustomAction>

</Elements>

But in this case, it is correctly redirected to the site collection. But it fails to get the folder url because current location can't pass through in this case. while creating new document.

Could you please suggest me either how to get the site collection url in the case 1 or how to pass the current location to the sourceul in case 2

© Stack Overflow or respective owner

Related posts about sharepoint2007

Related posts about feature