Always Create Your Own Group Templates with SharePoint Ribbon Customizations

Sunday, October 10, 2010 2:18 AM
Microsoft MVP Logo

When creating your own customizations for the SharePoint ribbon, a common task is to create a custom group for a new or existing tab in the ribbon. When you do this, you have to specify the group template that you want to use for the rendering of the controls in the group. The group template tells the ribbon how the group should be rendered in different states (scales) such as when the page is maximized, sized a bit smaller or even smaller. The SharePoint SDK does a good job of explaining how the group templates work.

Microsoft includes almost 30 different group templates in the SharePoint 2010 OOTB install, all found in the CMDUI.XML file ({SharePoint Root}\TEMPLATE\GLOBAL\XML folder). These are used but the ribbon implementations that Microsoft wrote. These OOTB templates are used by the SharePoint ribbon tabs and groups.

Naturally you might think “sweet, I’ll just find a group Microsoft created and use that in my ribbon customizations instead of going through the trouble of creating my own.” Hold up there… not so fast my friend…

I thought the same until I asked the guys behind the ribbon and started poking around. Apparently this is a very bad and dangerous idea. Why? The way the ribbon works is that it only loads the group templates on the page from the OOTB definitions, but it only does this for the OOTB ribbon referened group templates in the ribbon rendering for the current page. That means if you are using a group template that Microsoft created, you better hope the page your ribbon customizations are added to are using the same template.

So what should you do? Always create your own group template. Maybe you see one that Microsoft used and you want to use the same. In that case, copy Microsoft’s and put that in your ribbon customization to be safe and not make assumptions. Because, you know what they say about assumptions, they make something out of “you & me”.

comments powered by Disqus