Thursday, June 30, 2011

Custom Site Actions Fun

I recently had to update the Site Actions menu on a SharePoint 2010 Publishing site to override the standard New Page item with my own custom create page action and hide the other publishing options like Manage Site Content and Structure

The lure was to first go to the Master Page and update site actions there but this is a publishing site so there’s little that will do.

A quick google search brought back results about updating the CustomSiteActions.xml in the Styles Library/Editing Menus folder on the site.  Well that doesn’t help you either unless your on a MOSS 2007 site – the file is actually there in SP 2010 but only works for legacy purposes for upgraded SP 2007 sites.

A second google search for the same terms with the addition of “MSDN” in the search string brought me to all the MSDN articles to change site actions via a Visual Studio 2010 built feature.

So I built a feature.  I suggest using the Community Kit for SharePoint: Development Tools Edition from codeplex.  The toolkit gives you some more SharePoint 2010 project templates including a Custom Action which gives you a decent wizard for building your custom action.

I wanted to hide all the publishing features in the publishing site actions which turned out to be pretty easy by adding the HideCustomAction element as shown below to my custom actions element.  This blog was helpful in determining what to do about hiding items.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns=""> <CustomAction Description="Create Pages selecting from available page templates"
Title="Create Custom Pages">
<UrlAction Url="~sitecollection/_layouts/xyzco/xyzcreatepage.aspx" />

No comments:

Post a Comment