How to Customize (Add, Delete or Replace ) the "Site Action" menu items in Publishing site

The "Site Action" menu items in the SharePoint are rendered by the "CustomAction" feature framework. The story remains same untill the "Publishing Infrastructure Feature" is activated... When the publishing feature is activated and the site becomes SharePoint Publishing site then the datasource for the "SiteAction" menu items are rendered from the XML file which resides in 12 \ Template \ Layouts \ EditingMenu \ SiteAction.xml.

You cannot modify this "SiteAction.xml" file as it is OOB file and as well changing this file will affect the behavior in the total farm. SharePoint provides you a way to override the menu items rendered through the "SiteAction.xml" file. You can find the "Editing Menu" folder in the Master page gallery of the SharePoint publishing site, In this folder you can find the "CustomSiteAction.xml" file without the entries.

You can render your custom "Console Node" in this "CustomSiteAction.xml" to Add, Delete or replace the OOB console node links in the "Site Action" menu. Every menu item in the SiteAction.xml file has been rendered as a "ConsoleNode" class. Copy the references and the structure from the OOB "SiteAction.xml" and place it in the "CustomSiteAction.xml" file in the master page gallery. In the "ConsoleNode", you need to mention the "ConfigMenu" property to mention whether you are adding or deleting or replacing the console node in the "Site Action" menu. The enumerator value for Adding, Deleting and replacing the node are Add,Delete and Replace respectively.

Open the "CustomSiteAction.xml" file from the master page gallery. To add a console node you just need to add a "ConsoleNode" with the "ConfigMenu=Add" entry under the structure tag of the "CustomSiteAction.xml" file. To delete and replace the existing console node from the "Site Action" menu you need to mention another property called "ChangedNodeID" to mention the node id of the OOB file which need to be deleted or replaced.

The following "CustomSiteAction.xml" file is the sample to replace the "Create Page" console node link with the custom "Create Page" link where the custom link will navigate you to the "CustomCreatePage.aspx".

<?xml version="1.0" encoding="utf-8" ?>
<Console>
<references>
<reference TagPrefix="cms" assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions" />
</references>
<structure>
<ConsoleNode ConfigMenu="Replace" ChangedNodeID="wsaCreatePage" />
<ConsoleNode Action="cms:CreateNewPublishingPageAction" DisplayText="cms,siteactions_createpage_displaytext" Description="cms,siteactions_createpage_description" HideIfDisabled="true" UseResourceFile="true" MenuGroupId="100" Sequence="6000" IsSiteRelative="true" PermissionContext="CurrentList" ImageUrl="/_layouts/images/crtpage.gif" NavigateUrl="/_layouts/Customcreatepage.aspx" ID="wsaCreatePage1" />
</structure>
</Console>

In the above example , "ConfigeMenu" intimates that this "ConsoleNode" is replacing the OOB node "wsaCreatePage" with the new node "wsaCreatePage1" which redirects to the customcreatepage.aspx to create new publishing pages. Apart from this there are several other properties which can be set through the XML file itself such as "userRights" for permission mask etc. You can find more details about other properties here.

Save the "CustomSiteAction.xml" file in the master page gallery. Do an IISRESET and you can find your custom "Create Page" link which replaced teh OOB link and will navigate you to the "CustomCreatePage.aspx" to create the publishing pages.

You can refer more about the "ConsoleNode" and "SiteAction.xml" file in the following MSDN article.

https://msdn.microsoft.com/en-us/library/aa674506.aspx

You can find my another blog on how to create the "CustomCreatePage.aspx" application page to store the publishing pages in various lists rather than only in Pages list.

                                                                          HAPPY CUSTOMIZING