Adding Custom Site Actions Items to my SharePoint 2010 Blog

When you first create a blog on SharePoint 2010 it seems clunky in allowing the management of posts, comments, etc. Since I have a fixed width blog I don’t use the third column. Yes you can move the web part but what fun is that when we can try something new and add some links into the Site Actions.

Chances are I could have broken my site by doing this, but when working with SharePoint you should have NO Fear.  Understand that when you are working on customizing master pages you will break your site many many times, its just part of the process.

Adding the Custom items

Open your custom master page and find the last item of the <SharePoint:MenuItemTemplate…. code and copy and paste that into notepad or copy the following code into notepad:

<SharePoint:MenuItemTemplate runat="server" id="MenuItem_CommitNewUI"
  Text="<%$Resources:wss,siteactions_commitnewui%>"
  Description="<%$Resources:wss,siteactions_commitnewuidescription%>"
  ImageUrl="/_layouts/images/visualupgradehh.png"
  MenuGroupId="300"
  Sequence="330"
  UseShortId="true"
  ClientOnClickScriptContainingPrefixedUrl="GoToPage   
  ('~site/_layouts/prjsetng.aspx')"
  PermissionsString="ManageWeb"
  PermissionMode="Any"
  ShowOnlyIfUIVersionConfigurationEnabled="true" />


Note:
ID’s need to be unique make sure anything that uses an ID is changed.

My first custom Site Actions item was Create Post so I updated my copied code and made the first change ID (<SharePoint:MenuItemTemplate runat=”server” id=”CreatePost”). Again anything that uses an ID should be unique.

The text that is the heading or title of your action is simply called Text – Text=”<%$Resources:wss,siteactions_commitnewui%>” – remove the code and just add your own Text=”Create Blog Post”.

The description of your action is called Description – Description=”<%$Resources:wss,siteactions_commitnewuidescription%>”– remove the code and add your own Description=”Create a great Blog Post”.

So far you should have:

<SharePoint:MenuItemTemplate runat="server" id="CreatePost"
 Text="Create Blog Post"
 Description="Create a great blog post"

The next item to change is the Image URL. I am sure you can add you own image and link it to the URL, but I used what was already there. I found the items that had the icons I wanted to use and then went back through the code to copy that image url and added it to my code. If you make your own images make sure they have a transparent background and use the same size (32 x 32) as the existing icons.

ImageUrl="/_layouts/images/ActionsEditPage.png"

The site actions are broken up into Group ID’s and sequences. The last one  had a group ID of 300, set your group ID to 400.

Each item you add (Create Blog Post – 410, Manage Blog Post – 420 and Manage Comments – 430) will have a different sequence number. When creating my first item Create Blog Post I choose to sequence the items in groups of 10.

MenuGroupId="400"
Sequence="410"

Your code should look similar to this now.

<SharePoint:MenuItemTemplate runat="server" id="CreatePost"
 Text="Create Blog Post"
 Description="Create a great blog post"
 ImageUrl="/_layouts/images/ActionsEditPage.png"
 MenuGroupId="400"
 Sequence="410"

Next we want to change the

ClientOnClickScriptContainingPrefixedUrl="GoToPage('~site/_layouts/prjsetng.aspx')".

These are the links that will take us to Create and Manage Posts and Manage Comments. To get the correct URL you can use view source on your default blog page. The code you are looking for will be formatted in a LI. You can do a search in your view source for “Create a Post” and find the code you need to use. You would do the same for the other links you want to create.

<li>
<span style=”height:8px;width:8px;position:relative;display:inline-block;overflow:hidden;” ><a style=”display:inline-block;height:8px;width:8px;”><img src=”/_layouts/images/fgimg.png” style=”border:0;position:absolute;left:-0px !important;top:-447px !important;” /></a></span><a href=”javascript:” onclick=”javascript:ShowPopupDialog(‘/site/Blog/Lists/Posts/NewPost.aspx?Source=/site/Blog/‘)” id=”admlnk0″>Create a post</a>
</li>

Comparing my view source to the existing code it was easy to find the link I needed to use.

ClientOnClickNavigateUrl="~site/_layouts/settings.aspx"
ClientOnClickNavigateUrl="/hwaterman/blog/Lists
  /Posts/NewPost.aspx?Source=/hwaterman/blog/"

The remaining items are Permissions, I selected to use the same permissions as the Site Settings item, however you can use whatever permissions you want.

PermissionsString="EnumeratePermissions,ManageWeb,ManageSubwebs…"

That’s it, your code should now look like:

<SharePoint:MenuItemTemplate runat="server" id="CreatePost"
Text="Create Blog Post 
Description="Create a great blog post"
ImageUrl="/_layouts/images/ActionsEditPage.png"
MenuGroupId="400"
Sequence="410"
UseShortId="true"
ClientOnClickNavigateUrl="/hwaterman/blog/Lists
   /Posts/NewPost.aspx?Source=/hwaterman/blog/"
PermissionsString="EnumeratePermissions,ManageWeb,ManageSubwebs,
AddAndCustomizePages,ApplyThemeAndBorder,ManageAlerts,ManageLists,ViewUsageData"
PermissionMode="Any" />

I am sure this can be used for a number of different shortcuts you might want to place in the Site Actions of your custom master page.

Thanks for reading!

, , , , , ,