I had a curious problem today. I was registering Custom Actions to create a TabGroup with a single Button control on SharePoint’s ribbon:
I did this following Chris O’Brien’s post about “Adding ribbon items to existing tabs/groups“. It worked well, except that as we’re not registering the custom action against a particular list type (e.g. “101”), this button will appear on any list using the tab specified in the CommandUIDefinition‘s Location. In other words, for this example, any list with a ‘Library’ tab:
<CustomAction Id="My.DocumentLibraryTab" Location="CommandUI.Ribbon"> <CommandUIExtension> <CommandUIDefinitions> <CommandUIDefinition Location="Ribbon.Library.Groups._children"> <Group Id="My.DocumentLibraryTab.ClassificationGroup" Sequence="45" Description="My Library Classification" Title="My" Template="Ribbon.Templates.Flexible"> <Controls Id="My.DocumentLibraryTab.ClassificationGroup.Controls"> <Button Id="My.DocumentLibraryTab.ClassificationGroup.ClassifyList" Command="My.Command.ClassifyList" Sequence="45" Image16by16="/_layouts/images/My/ClassifyList_16x16.png" Image32by32="/_layouts/images/My/ClassifyList_32x32.png" Description="Submit an entire Library for classification." LabelText="Classify Library" TemplateAlias="o1" /> </Controls> </Group> </CommandUIDefinition> </CommandUIDefinitions>
This was a problem was, this button should only appear for a particular type of list. I changed the CustomAction to register against a particular type of list:
<CustomAction Id="Smartlogic.Semaphore.DocumentLibraryTab" Location="CommandUI.Ribbon" RegistrationId="101" RegistrationType="List">
Ribbon.Templates.Flexible could not be loaded
Interesting. Armed with that, I did some digging, and then as I came to the same conclusion, I found Andrew Connell’s post ‘Always Create Your Own Group Templates with SharePoint Ribbon Customizations’. The problem was that while I wasn’t registering my TabGroup against a particular type of list, the CMDUI.xml file was being loaded – so the out of the box templates were available. However, once I tried registering the tabgroup against a particular type of list, they weren’t loaded – so the template was unavailable, and hence just script.
So just do what Andrew Connell says – define your own. I ended up copying the one I wanted from CMDUI.xml and including it into my custom action.