Sample: Add Ribbon Button to Content Type

Adds a Button to a Content Type specific ribbon.

Recipe Description

In this sample a custom ribbon button is added to the edit form of the content type Document (0x0101). The following code adds the button to the actions group.
  
  <CustomAction
    Id="Ribbon.RibbonContentType"
    Location="CommandUI.Ribbon"
    Title="RibbonContentType"
    RegistrationType="ContentType"
    RegistrationId="0x0101">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.DocLibListForm.Edit.Actions.Controls._children">
          <Button
            Id="Ribbon.RibbonContentType.Button"
            Command="RibbonContentType.ButtonCommand"
            Sequence="500"
            Image16by16="/_layouts/images/RibbonIcon_RibbonContentType_16.gif"
            Image32by32="/_layouts/images/RibbonIcon_RibbonContentType_32.gif"
            LabelText="ContentType Button"
            ToolTipTitle="ContentType Button"
            ToolTipDescription="Description of ContentType Button"
            TemplateAlias="o2" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="RibbonContentType.ButtonCommand"
          CommandAction="javascript:alert('Hello, world');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
        

Screens


Arguments

Name Description
General Settings
Name Required Text. Specifies the name of the button control.
Title Required Text. The text to label the control.
Description Required Text. The text that appears as the description of the tooltip.
Sequence Required Integer. An integer that specifies the order of placement among sibling XML nodes.
Optional Permission Settings
Rights Optional Text. Specifies a set of rights that the user must have in order for the link to be visible. If not specified, then the action always appears in the list of actions. The set of rights are grouped logically according to AND logic.
Require Site Administrator Optional Boolean. TRUE to specify that the item be displayed only if the user is a site administrator; otherwise, FALSE. Using the RequireSiteAdministrator attribute for the drop-down menu of Windows SharePoint Services commands associated with list items is not supported.
Form Settings
Custom Action Location Required Text. Location element of the custom action.
Optional List Settings
Content Type Select the content type where the action should be added.
Location Settings
Parent Ribbon Group Required Text. Specifies the existing ribbon group into which the new button should be added.

References

Authors

  • Torsten Mandelkow

Version history

  • 1.0 Initial Recipe