I would like to add a button into the Web Part Tools ribbon section.
I have looked in CMDUI.XML to find the other buttons which are in this section and it appears they should be under Ribbon.WebPartOption.
and i have tried a bunch of different paths under this but havent managed to get a button to show up. Below is my current code:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="AddAsDashboardItem"
Location="CommandUI.Ribbon"
Sequence="5">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.WebPartOption.Properties.Controls._children">
<Button
Id="Ribbon.WebPartOption.Commands.AddAsDashboardItemButton"
Command="AddAsDashboardItem_Button"
Sequence="5"
Image16by16="/_layouts/images/Dashboard2010/AddDashboardItem_16x16.bmp"
Image32by32="/_layouts/images/Dashboard2010/AddDashboardItem_32x32.bmp"
LabelText="Add As Dashboard Item"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="AddAsDashboardItem_Button"
CommandAction="javascript:alert('SharePoint ribbon button');" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
Does anyone know what location i need to put a button in this section of the ribbon?
EDIT
I tried to add it into my own group and I got the following:
There's a group there but no button. My code below:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Ribbon.WebPartOption.Dashboard"
Location="CommandUI.Ribbon"
Sequence="5">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.WebPartOption.Groups._children">
<Group
Id="Ribbon.WebPartOption.Dashboard.Group"
Sequence="70"
Title="Dashboards"
Template="Ribbon.Templates.ManageViewsGroup">
<Controls Id="Ribbon.WebPartOption.Dashboard.Group.Controls">
<Button
Id="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Button"
Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
Sequence="1"
Image16by16="/_layouts/images/Dashboard2010/AddDashboardItem_16x16.bmp"
Image32by32="/_layouts/images/Dashboard2010/AddDashboardItem_32x32.bmp"
LabelText="Add As Dashboard Item"
TemplateAlias="o1" />
</Controls>
</Group>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
CommandAction="javascript:alert('SharePoint ribbon button');" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
EDIT2:
It ended up that I also needed to define scaling options. Below is a working example:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Ribbon.WebPartOption.Dashboard"
Location="CommandUI.Ribbon"
Sequence="5">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.WebPartOption.Groups._children">
<Group
Id="Ribbon.WebPartOption.Dashboard.Group"
Sequence="70"
Title="Dashboards"
Template="Ribbon.Templates.Flexible2">
<Controls Id="Ribbon.WebPartOption.Dashboard.Group.Controls">
<Button
Id="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Button"
Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
Sequence="1"
Image16by16="/_layouts/images/Dashboard2010/AddDashboardItem_16x16.bmp"
Image32by32="/_layouts/images/Dashboard2010/AddDashboardItem_32x32.bmp"
LabelText="Add As Dashboard Item"
TemplateAlias="o1" />
</Controls>
</Group>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.WebPartOption.Scaling._children">
<MaxSize Id="Ribbon.WebPartOption.Dashboard.MaxSize"
GroupId="Ribbon.WebPartOption.Dashboard.Group"
Sequence="20"
Size="LargeLarge"/>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.WebPartOption.Scaling._children">
<MaxSize Id="Ribbon.WebPartOption.Dashboard.MediumMedium"
GroupId="Ribbon.WebPartOption.Dashboard.Group"
Sequence="30"
Size="MediumMedium"/>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.WebPartOption.Scaling._children">
<MaxSize Id="Ribbon.WebPartOption.Dashboard.Popup"
GroupId="Ribbon.WebPartOption.Dashboard.Group"
Sequence="20"
Size="Popup"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
CommandAction="javascript:alert(getId());" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>