Customize Site Action Menu in SharePoint


Here I am going to show, how to create Site Action Menu Customize in Sharepoint site.

For that we have to know that what is custom action ?

Custom Actions

Custom actions are links, toolbar buttons and menu items that you can add to or hide from the SharePoint's user interface. Each custom action exists in a specific location, and depending on that location, can be a part of a group of actions.

With a custom action feature, you can:

  • Add a new Custom Action Group which can be used to group custom actions in a specific options screen;
  • Add a new Custom Action which can be a new option in a settings screen, a new menu item, or a new toolbar button;
  • Hide an existing Custom Action whether that action is the result of custom action feature or it belongs to SharePoint's out-of-the-box features.

Now we start Customize SiteAction Menu For that we have make two XML file Like Feature.xml and Element.xml.

Feature Manifest

I will only present a simple feature manifest; you can put your xml file on C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES path within New Folder. Like: UserInterfaceCustomActions folder pastes that feature.xml file.

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

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

         Id="5DFD12AF-D0AA-4c63-8FB8-C49DB1191083"

         Title="My Custom Action Feature"

         Description="Adds Custom Actions to the Web Site."

         Scope="Web"

         Version="1.0.0.0">

    <ElementManifests>

        <ElementManifest Location="CustomActions.xml"/>

    </ElementManifests>

</Feature>

Notes about this feature manifest:

  • The title of the feature is My Custom Actions Feature.
  • It will be deployed as a Web Site feature, since its Scope value is Web.
  • It references a single element manifest file: CustomActions.xml.

Element Manifest

The element manifest file can have any name you wish (in this example it's called CustomActions.xml), but it's root element must be <Elements>. Inside this root element, you can place any number of feature element descriptions. In this example I will present the use of three feature elements:

  • <CustomActionGroup> used to create new custom action groups;
  • <CustomAction> used to create new custom actions;
  • <HideCustomAction> used to hide existing actions.

<?xml version="1.0" encoding="utf-8" ?>
<
Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!--
Custom Action Group -->
    <
CustomActionGroup
       
Id="MyActionGroup"
        Description="This group contains all my custom actions."
        Title="My Action Group"
        Location="Microsoft.SharePoint.SiteSettings"
        Sequence="30" />

    <!-- Custom Action in Custom Action Group -->
    <
CustomAction
       
Id="MyCustomAction"
        Description="This link is a custom action."
        Title="My Custom Action"
        GroupId="MyActionGroup"
        Location="Microsoft.SharePoint.SiteSettings"
        Rights="ManageWeb"
        RequireSiteAdministrator="FALSE"
        Sequence="20">

        <
UrlAction Url="~sitecollection/_layouts/MyCustomPage1.aspx" />
    </
CustomAction>

    <!-- Custom Action in Site Actions Menu -->
    <
CustomAction
       
Id="MyNewCustomAction"
        Description="This menu item is a new custom action."
        Title="My New Custom Action"
        GroupId="SiteActions"
        Location="Microsoft.SharePoint.StandardMenu"
        ImageUrl="/_layouts/MyActionIcon.jpg"
        Sequence="10">

        <
UrlAction Url="~sitecollection/_layouts/MyCustomPage2.aspx" />
    </
CustomAction>

    <!-- Hide Custom Action -->
    <
HideCustomAction
        
Id="HideDeleteWeb"
        GroupId="SiteAdministration"
        Location="Microsoft.SharePoint.SiteSettings"
        HideActionId="DeleteWeb" />

</
Elements>
 
In command prompt, type the following commands to install the Feature in the deployment, activate the feature on a specified sub site, and then reset Microsoft Internet Information Services (IIS) so that the changes can take effect 

  1. stsadm -o installfeature -filename UserInterfaceCustomActions\feature.xml
  2. stsadm -o activatefeature -filename UserInterfaceCustomActions\feature.xml -url http://Server/Site/Subsite
  3. Iisreset.

Now you can open the site which gave URL in above command no. b and then go to site Action menu on left hand side on site and show your custom site action menu like My New Custom Action.

Now Enjoy with the Customize Site Action Menu.

Recommended Ebook

SharePoint Framework (SPFx) A Developers Guide

Download Now!
Similar Articles