Extend SharePoint 2010 User Interface for Lists - Ribbon, Menus & Toolbars - SharePoint Development & Administration + InfoPath

Sunday, November 13, 2011

Extend SharePoint 2010 User Interface for Lists - Ribbon, Menus & Toolbars

In my previous post, I demonstrated how to customise the User Interface for Libraries in SharePoint 2010 by adding links / custom actions in existing Menus, the Ribbon and Document Library Settings pages.
This post follows on by demonstrating how to customise the interface for different types of lists built into SharePoint 2010 by adding new custom actions to the menus and existing groups in the Ribbon.

Contents:

1. Extending the User Interface for Items
  • 1.1 Add a custom link to the List Item Menu (ECB / LIM) for an Announcements list
  • 1.2 Add a Custom Action to the “Manage” group in the Events tab of a Calendar / Events List
2. Customise the “New” menu and “New” Group on Ribbon for a Task List in SharePoint 2010
  • 2.1 Add a Link to the New menu for a Task List
  • 2.2 Add a Custom Control to the existing New Group in the Items tab on the Ribbon for a Task List
3. Add a link to the Custom Actions Group for a Links List in SharePoint 2010
  • 3.1 Add a Custom Action to the Actions Menu and “Custom Actions” tab for a Links list in SharePoint 2010
  • 3.2 Add A Custom Link to the existing “Share & Track” group on the List tab of the Ribbon for a Links List
  • 3.3 Add A Custom Link to the Manage Views Group on the List tab of the Ribbon
4. Add a link to the Settings Groups for a Calendar / Events List in SharePoint 2010
  • 4.1 Add a custom link to the Settings menu for a Calendar list in SharePoint 2010
  • 4.2 Add a Custom Action to the Settings Group on the Ribbon for a Calendar in SharePoint 2010
  • 4.3 Add a Custom Button / Link to the “Customize List” group in the Calendar tab on the Ribbon
5. Add custom links to the Settings page for a Discussion Board in SharePoint 2010
  • 5.1 Add a custom link to an existing group/heading on the Settings page for a Discussion Board in SharePoint 2010




RegistrationId’s for built-in List types in SharePoint 2010
Below is a list of the Registration ID’s for some of the common built-in List types used in SharePoint. The List Registration IDs can be used when creating custom actions to target a specific list type such as an Announcements, Links or Task list.


RegistrationIdList Template / Description
100Generic List, Custom List
103Links List
104Announcements List
105Contacts List
106Calendar / Events List
107Task List
108Discussion Board
112User Information List (List of Users on each site)
120Custom List
600External List
1100Issue Tracking List

A reference to a comprehensive list of Registration IDs for List Templates in SharePoint is provided later in the post, which includes code to retrieve a list of Registration IDs for each list templates included in the SPListTemplateType enumeration.

The examples in this tutorial will use a range of Registration IDs from the table above to add Custom Actions to the Ribbon and List Menus for different types of lists in SharePoint 2010.

1. Extending the User Interface for Items
There are a number of components of the User Interface in SharePoint 2010 that contain actions that can be performed on items in a list as opposed to the List itself. These actions are accessible from the “Items” tab on the Ribbon and the dropdown menu for items known as the Edit Control Block (ECB), or List Item Menu (LIM) in SharePoint 2010. Many actions available on the Items tab for list items are only enabled when there are items selected from the list below. Similar functionality can also be achieved when adding custom actions to the Ribbon for list items to test if there are items selected. The examples below require that one or more items in selected for the control to be enabled.

1.1 Add a custom link to the List Item Menu (ECB / LIM) for an Announcements list
The following CustomAction is added to the Edit Control Block (List Item Dropdown Menu) for Announcement items in Announcement Lists.


<!-- EditControlBlock Item Dropdown (Announcements List) : Example 1.1 -->  
<CustomAction 
Id="Announcements.EditControlBlock.CustomLink"
  RegistrationType="List"
  RegistrationId="104"
  Location="EditControlBlock"
  Sequence="1101"
  Title="EditControlBlock : Custom Link"
  Description="Custom link on item dropdown menu (LIM / ECB) for an Announcement">
  <UrlAction Url="http://blog-sharepoint.blogspot.com/"/> 
</CustomAction>




List Type / Template:
Announcements List
CustomAction Registration ID: 104
CustomAction Location:  EditControlBlock

1.2 Add a Custom Action to the “Manage” group in the Events tab of a Calendar / Events List
This Action is added to the Manage Group in the Events tab on the Ribbon, and is available from a standard view (not included on the Ribbon when the Ribbon when the calendar view is displayed). When the calendar view is displayed, the Manage group on the events tab has a different location (Ribbon.Calendar.Events.Manage).


<!-- Ribbon - Manage Group (Events List / Calendar) : Example 1.2 -->
  <CustomAction
  Id="Ribbon.ListItem.Manage.Controls.CustomLink"
  Location="CommandUI.Ribbon"
  RegistrationId="106"
  RegistrationType="List" 
Title="Add to Existing Group">
  <CommandUIExtension>
  <CommandUIDefinitions> 
<CommandUIDefinition 
Location="Ribbon.ListItem.Manage.Controls._children">
  <Button
  Id="Ribbon.ListItem.Manage.Controls.CustomLink"
  Sequence="95"
  Command="ListItem.Manage.OpenCustomLink"
  Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png"
  Image16by16Top="-32" Image16by16Left="-88"
  Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png"
  Image32by32Top="-160" Image32by32Left="-448"
  LabelText="Manage Group : Custom Link"
  Description="Open Custom Link"
  ToolTipTitle="Custom Action in Manage Group"
  ToolTipDescription="Opens a custom link from a button in the Manage Group for an Events List if one event is selected."
  TemplateAlias="o1" />
  </CommandUIDefinition> 
</CommandUIDefinitions>
  <CommandUIHandlers>
  <CommandUIHandler 
Command="ListItem.Manage.OpenCustomLink"
  CommandAction="http://blog-sharepoint.blogspot.com/"
  EnabledScript="javascript:
function hasSelectedEvents(){
var selectedEvents = SP.ListOperation.Selection.getSelectedItems();
var selectedEventCount = CountDictionary(selectedEvents);
//Enable the button if one event item is selected.
if(selectedEventCount == 1)
return true;
else
return false;
};
// Check if Event Items are selected on the page
hasSelectedEvents();
"/>
  </CommandUIHandlers> 
</CommandUIExtension> 
</CustomAction>




List Type / Template: Events List
CustomAction Registration ID: 106
CustomAction Location: CommandUI.Ribbon
CommandUIDefinition Location: Ribbon.ListItem.Manage.Controls._children


2. Customise the “New” menu and “New” Group on Ribbon for a Task List in SharePoint 2010
In this section as well as the ones to follow, I demonstrate how to add Custom Actions to existing groups and menus in the SharePoint 2010 User Interface for lists.

In SharePoint 2007 (MOSS), the list toolbar containing the New, Actions and Settings menus is displayed by default when viewing a list on a page. In SharePoint 2010 the functionality from these menus is available from the Custom Commands tab on the Server Ribbon as well as the toolbar menus, but the toolbar is not displayed for lists by default.

2.1 Add a Link to the New menu for a Task List
This custom action is added to the New menu on the toolbar if the toolbar is visible on the list view of a Task List. If the toolbar is not visible (default), the action is included in a “Custom Commands” tab and group on the Ribbon. When the toolbar is enabled that contains the New menu and custom action, the Custom Commands tab on the Ribbon is not displayed.


<!-- New Menu (Task List) : Example 2.1 -->
  <CustomAction Id="Microsoft.SharePoint.StandardMenu.TaskList.NewMenu.CustomLink"
  RegistrationType="List"
  RegistrationId="107"
  GroupId="NewMenu"
  Location="Microsoft.SharePoint.StandardMenu"
  Sequence="1101"
  Description="Custom Action in New Menu for Task Lists"
  Title="New Menu : Custom Link">
  <UrlAction Url="http://blog-sharepoint.blogspot.com/"/>
  </CustomAction>



[New menu action in Custom Commands group when list toolbar is not enabled]


[New menu custom action when toolbar is visible]

List Type / Template: Task List
CustomAction Registration ID: 107
CustomAction Location: Microsoft.SharePoint.StandardMenu
CustomAction Group ID: NewMenu


2.2 Add a Custom Control to the existing New Group in the Items tab on the Ribbon for a Task List
This custom control is included in the New Group on the Server Ribbon in the Items tab for Task Lists.


<!-- Ribbon - New Group (Task List) : Example 2.2 -->
  <CustomAction Id="Ribbon.ListItem.New.Controls.CustomLink"
  Location="CommandUI.Ribbon"
  RegistrationId="107"
  RegistrationType="List"
  Title="Add to Existing New Group on the Ribbon">
  <CommandUIExtension> 
<CommandUIDefinitions> 
<CommandUIDefinition 
Location="Ribbon.ListItem.New.Controls._children"> 
<Button 
Id="Ribbon.ListItem.New.CustomLink"
  Sequence="95" 
Command="ListItem.New.OpenCustomLink"
  Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" 
Image16by16Top="-32" Image16by16Left="-88"
  Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png"
  Image32by32Top="-160" Image32by32Left="-448"
  LabelText="New Group : Custom Link"
  Description="Open Custom Link"
  ToolTipTitle="Custom Action in New Group"
  ToolTipDescription="Opens a link from a control added to the New group on the Ribbon (Items tab) for a Task list" 
TemplateAlias="o1" />
  </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
  <CommandUIHandler
  Command="ListItem.New.OpenCustomLink"
  CommandAction="http://blog-sharepoint.blogspot.com/"
  />
  </CommandUIHandlers>
  </CommandUIExtension> 
</CustomAction>




List Type / Template: Task List
CustomAction Registration ID: 107
CustomAction Location: CommandUI.Ribbon
CommandUIDefinition Location: Ribbon.ListItem.New.Controls._children


3. Add a link to the Custom Actions Group for a Links List in SharePoint 2010

3.1 Add a Custom Action to the Actions Menu and “Custom Actions” tab for a Links list in SharePoint 2010
When creating a Custom Action to be included in the Actions menu of a links list, this will also add a control to the Ribbon in a “Custom Commands” group on the Ribbon if the toolbar is not visible. The same Location and Group ID in MOSS 2007 and (SharePoint 2010) are used to include the custom action in the Actions menu as well.


<!-- Actions Menu (Links List) : Example 3.1 -->
  <CustomAction Id="Microsoft.SharePoint.StandardMenu.LinksList.ActionsMenu.CustomLink" 
RegistrationType="List"
  RegistrationId="103"
  GroupId="ActionsMenu"
  Location="Microsoft.SharePoint.StandardMenu"
  Sequence="1101"
  Title="Actions Menu : Custom Link" 
Description="Adds a custom control to a Custom Actions group on the Ribbon and the Actions menu for Links Lists">
  <UrlAction Url="http://blog-sharepoint.blogspot.com/"/>
  </CustomAction>


[Actions Menu of Links List when the list toolbar is visible]


[Custom commands group displaying "Actions" menu item when toolbar not enabled]

List Type / Template: Links List
CustomAction Registration ID: 103
CustomAction Location: Microsoft.SharePoint.StandardMenu
CustomAction Group ID: ActionsMenu


3.2 Add A Custom Link to the existing “Share & Track” group on the List tab of the Ribbon for a Links List
This will add a new control to the Share & Track group on the List tab of the Ribbon for Links lists.


<!-- Ribbon - Share & Track Group (Links List) : Example 3.2 -->
  <CustomAction Id="Ribbon.List.Share.Controls.CustomLink"
  Location="CommandUI.Ribbon" 
RegistrationId="103" 
RegistrationType="List" 
Title="Add to Existing Group"> 
<CommandUIExtension> 
<CommandUIDefinitions> 
<CommandUIDefinition
  Location="Ribbon.List.Share.Controls._children">
  <Button
  Id="Ribbon.List.Share.CustomLink"
  Sequence="95" 
Command="List.Share.OpenCustomLink"
  Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png"
  Image16by16Top="-32" Image16by16Left="-88"
  Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png"
  Image32by32Top="-160" Image32by32Left="-448"
  LabelText="Share &amp; Track Group : Custom Link"
  Description="Open Custom Link"
  ToolTipTitle="Custom Action in Share &amp; Track Group"
  ToolTipDescription="Opens a link via a button in the Share &amp; Track group (List tab) for Links lists"
  TemplateAlias="o1" />
  </CommandUIDefinition> 
</CommandUIDefinitions>
  <CommandUIHandlers> 
<CommandUIHandler
  Command="List.Share.OpenCustomLink"
  CommandAction="http://blog-sharepoint.blogspot.com/"
  />
  </CommandUIHandlers> 
</CommandUIExtension> 
</CustomAction>


List Type / Template: Links List
CustomAction Registration ID: 103
CustomAction Location: CommandUI.Ribbon
CommandUIDefinition Location: Ribbon.List.Share.Controls._children

3.3 Add A Custom Link to the Manage Views Group on the List tab of the Ribbon
This will add a new Custom Action control to the Manage Views group on the List tab of the Ribbon for Links Lists.


<!-- Ribbon - Manage Views Group (Links List) : Example 3.3 --> 
<CustomAction Id="Ribbon.List.CustomViews.Controls.CustomLink"
  Location="CommandUI.Ribbon"
  RegistrationId="103"
  RegistrationType="List" 
Title="Add to Existing Group"> 
<CommandUIExtension>
  <CommandUIDefinitions>
  <CommandUIDefinition
  Location="Ribbon.List.CustomViews.Controls._children"> 
<Button
  Id="Ribbon.List.CustomViews.CustomLink"
  Sequence="95" 
Command="List.CustomViews.OpenCustomLink"
  Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" 
Image16by16Top="-32" Image16by16Left="-88"
  Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png"
  Image32by32Top="-160" Image32by32Left="-448" 
LabelText="Manage Views Group : Custom Link" 
Description="Open Custom Link"
  ToolTipTitle="Custom Action in Manage Views Group"
  ToolTipDescription="Opens a link from a button in the Manage Views group (List tab) on the Ribbon for Links Lists"
  TemplateAlias="o1" /> 
</CommandUIDefinition> 
</CommandUIDefinitions> 
<CommandUIHandlers>
  <CommandUIHandler
  Command="List.CustomViews.OpenCustomLink"
  CommandAction="http://blog-sharepoint.blogspot.com/"
  />
  </CommandUIHandlers>
  </CommandUIExtension> 
</CustomAction>



List Type / Template: Links List
CustomAction Registration ID: 103
CustomAction Location: CommandUI.Ribbon
CommandUIDefinition Location: Ribbon.List.CustomViews.Controls._children


4. Add a link to the Settings Groups for a Calendar / Events List in SharePoint 2010


4.1 Add a custom link to the Settings menu for a Calendar list in SharePoint 2010
The following Custom Action is included in the Settings Menu of a calendar list when the toolbar is enabled. If the list toolbar is not visible, the Action is included in a Custom Commands tab and group on the Ribbon.


<!-- Settings Menu (Events List / Calendar) : Example 4.1 -->
  <CustomAction Id="Microsoft.SharePoint.StandardMenu.Events.SettingsMenu.CustomLink"
  RegistrationType="List"
  RegistrationId="106" 
GroupId="SettingsMenu"
  Location="Microsoft.SharePoint.StandardMenu"
  Sequence="1101"
  Title="Settings Menu : Custom Link" 
Description="Custom link in the Settings menu for Events Lists">
  <UrlAction Url="http://blog-sharepoint.blogspot.com/"/>
  </CustomAction>



[Events List Settings Menu item displayed in Custom Commands group on Ribbon when Toolbar not enabled]


 [Events list / Calendar Settings menu item when the list toolbar is visible]

List Type / Template: Events List
CustomAction Registration ID: 106
CustomAction Location: Microsoft.SharePoint.StandardMenu
CustomAction Group ID: SettingsMenu


4.2 Add a Custom Action to the Settings Group on the Ribbon for a Calendar in SharePoint 2010
This Custom Action is included in the Settings group on the List tab for an Events list when viewing a list of the event item in the list. When the Calendar is displayed using the Calendar View, the custom actions are not included in the Settings group. Ribbon.Calendar.Calendar.CustomizeList would need to be used for the location to include in the Settings group in Calendar Views.


<!-- Ribbon - Settings Group (Events List / Calendar) : Example 4.2 --> 
<CustomAction Id="Ribbon.List.Settings.Controls.CustomLink"
  Location="CommandUI.Ribbon" 
RegistrationId="106"
  RegistrationType="List"
  Title="Add to Existing Group">
  <CommandUIExtension>
  <CommandUIDefinitions> 
<CommandUIDefinition 
Location="Ribbon.List.Settings.Controls._children">
  <Button
  Id="Ribbon.List.Settings.CustomLink"
  Sequence="95" 
Command="List.Settings.OpenCustomLink"
  Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png"
  Image16by16Top="-32" Image16by16Left="-88" 
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png"
  Image32by32Top="-160" Image32by32Left="-448"
  LabelText="Settings Group : Custom Link"
  Description="Open Custom Link"
  ToolTipTitle="Custom Action in Settings Group"
  ToolTipDescription="Opens a link from a button in the Settings Group (Calendar tab) for Events lists."
  TemplateAlias="o1" />
  </CommandUIDefinition> 
</CommandUIDefinitions>
  <CommandUIHandlers> 
<CommandUIHandler 
Command="List.Settings.OpenCustomLink"
  CommandAction="http://blog-sharepoint.blogspot.com/"
  />
  </CommandUIHandlers>
  </CommandUIExtension>
  </CustomAction>


List Type / Template: Events List
CustomAction Registration ID: 106
CustomAction Location: CommandUI.Ribbon
CommandUIDefinition Location: Ribbon.List.Settings.Controls._children

4.3 Add a Custom Button / Link to the “Customize List” group in the Calendar tab on the Ribbon
Ads a new control to the Ribbon for Events list when viewing a list of events. Similar to the examples above, the location for this custom action results in the Customize List group on the List tab being targeted so the control is not included in the Customize List tab on the calendar tab when the Calendar view is displayed. The location would need to be set to Ribbon.Calendar.Calendar.CustomizeList to include in the Customize List group on the Calendar tab.


<!-- Ribbon - Customize List Group (Events List / Calendar) : Example 4.3 -->
  <CustomAction Id="Ribbon.List.CustomizeList.Controls.CustomLink"
  Location="CommandUI.Ribbon"
  RegistrationId="106"
  RegistrationType="List"
  Title="Add to Existing Group"> 
<CommandUIExtension> 
<CommandUIDefinitions>
  <CommandUIDefinition
  Location="Ribbon.List.CustomizeList.Controls._children"> 
<Button 
Id="Ribbon.List.CustomizeList.CustomLink"
  Sequence="95"
  Command="List.CustomizeList.OpenCustomLink" 
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" 
Image16by16Top="-32" Image16by16Left="-88" 
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png"
  Image32by32Top="-160" Image32by32Left="-448"
  LabelText="Customize LIst Group : Custom Link"
  Description="Open Custom Link"
  ToolTipTitle="Custom Action in Customize List Group"
  ToolTipDescription="Opens a link from a button included in the Customize List group (Calendar tab) on the Ribbon for Events Lists"
  TemplateAlias="o1" />
  </CommandUIDefinition> 
</CommandUIDefinitions>
  <CommandUIHandlers>
  <CommandUIHandler
  Command="List.CustomizeList.OpenCustomLink"
  CommandAction="http://blog-sharepoint.blogspot.com/"
  />
  </CommandUIHandlers> 
</CommandUIExtension>
  </CustomAction>


List Type / Template: Events List
CustomAction Registration ID: 106
CustomAction Location: CommandUI.Ribbon
CommandUIDefinition Location: Ribbon.List.CustomizeList.Controls._children


5. Add custom links to the Settings page for a Discussion Board in SharePoint 2010

5.1 Add a custom link to an existing group/heading on the Settings page for a Discussion Board in SharePoint 2010
This custom action will add a new link to the Settings page for Discussion Board lists under the Permissions Heading. “Permissions” is set as the GroupId for the Custom Action to target the Permissions and Management group on the page. Supplying “GeneralSettings” for the Group ID would include the link under the General Settings heading. “Communications” should be used to include a custom action under the Communication heading on the List settings page.


<!-- Settings Page - Permissions & Management Heading (Discussion Board) : Example 5.1 -->
  <CustomAction 
Id="Microsoft.SharePoint.ListEdit.Discussions.Permissions.CustomLink" 
RegistrationType="List"
  RegistrationId="108"
  GroupId="Permissions"
  Location="Microsoft.SharePoint.ListEdit"
  Sequence="1000" 
Title="List Settings Page - Permissions and Management : Custom Link"
  Description="Adds a new link under the Permissions and Management heading on the Settings Page for a Discussions List / Discussion Board."> 
<UrlAction Url="http://blog-sharepoint.blogspot.com/"/>
  </CustomAction>





List Type / Template: Discussion Board / Discussions List
CustomAction Registration ID: 108
CustomAction Location: Microsoft.SharePoint.ListEdit
CustomAction Group ID: Permissions


More information on Customising / Extending the User Interface and Ribbon for Lists:

Add Custom Actions to the Interface for Document Libraries in SharePoint 2010
This is the previous post in this series, which focuses on customising the interface for different types of Document Libraries in SharePoint 2010. A range of examples are included to add links to existing menus and groups on the Ribbon.

Apply Permissions to Custom UI Links / Actions in SharePoint Menus and Settings Pages
This post explains how to integrate permissions into Custom Actions to restrict who has access to specific Custom Actions added to the interface. The Rights attribute of the CustomAction element is used, which contains one or more values from the SPBasePermissions enum.

Tutorial: Add Custom List actions using SharePoint Designer 2010
In SharePoint 2010, the Ribbon and toolbars for Lists can be customised using functionality provided by SharePoint Designer 2010. This tutorial provides information about these feayures, and explains the process of adding custom actions to lists in SharePoint 2010 using SharePoint Designer instead of using a Feature.

Add Custom Links to the SharePoint 2010 UI as a Feature with or without using Visual Studio
This tutorial demonstrates two methods for implementing customisations to the User Interface as a feature by either incorporating into a solution in Visual Studio, or by manually creating the Feature XML and installing using STSADM or PowerShell.

RegistrationId’s for List Types in SharePoint
This is a reference article by Mike Smith that includes a list of Registration Ids for different types of built-in list templates for SharePoint. Code is also included to list the values from the SPListTemplateType enum.

How to: Modify the User Interface Using Custom Actions
This is a “How To” article on MSDN that demonstrates how to use Custom Actions to Modify the User Interface, including customisations to the Ribbon, lists and sites.
Share this article:
Stumble This Delicious
Delicious
submit to reddit
Facebook
MySpace
MySpace

No comments:

Post a Comment