Wednesday, April 21, 2010

Adding/Customizing action menu in SharePoint

 
 

A common requirement  that every Sharepoint developer is asked for today is customization of the SharePoint site based on various customer specific requirements. Most often customers have requirements where they want to add some additional features to action menus like Site action menu, ECB menu or List/library Action menu, etc. To achieve this, we have to write custom action in XML and consume it within the site as a new feature. In Sharepoint if we need to integrate new feature for a List / Library, we can achieve this easily by creating a custom action feature. 

  

1. Create a folder named TestCustomAction under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES directory.

 
 

2. Next, create a file named Feature.xml in the same folder with the following codes.

 
 

<?xml version="1.0" encoding="utf-8" ?>

<Feature Id="0BFF73A7-01ED-41e0-A810-3C764AC5201C" Title="Create new link in action Menu" Description="Add a new link to the action menu of a Custom List." Version="1.0.0.0" Scope="Site" xmlns="http://schemas.microsoft.com/sharepoint/">

<ElementManifests>

<ElementManifest
Location="TestCustomActions.xml" />

</ElementManifests>

</Feature>

 
 

3. Next, create another file, TestCustomActions.xml in the same folder with the following codes

 
 

<?xml version="1.0" encoding="utf-8" ?>

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

<CustomAction Id="UserInterfaceCustomActions.DocLibActionsToolbar" RegistrationType="List" RegistrationId="100" GroupId="ActionsMenu" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Generate CSV file for the Custom List">

                                <UrlAction
Url="/_layouts/TestCustomActions.aspx?List={ListId}" />

                </CustomAction>

   </Elements>

 
 

4. Create a page named TestCustomActions.aspx under layouts folder and add your own Business Logic.

 
 

5. Finally, deploy this feature by running the command in the command prompt.

 
 

To activate this feature: stsadm -o installfeature -filename TestCustomAction\feature.xml -url http://TestServer/Site.

 
 

Finally to see the changes in the site do an iisreset.

0 comments: