Create Custom Group Templates for Custom SharePoint Ribbons

Learn why using the out-of-the-box (OOTB) group templates for customizing the SharePoint ribbon is a bad idea - always create your own group templates.

This post is part of a series on SharePoint 2010 ribbon development. The other posts in this series can be found here: SharePoint 2010 Ribbon Development Series

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 referenced 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”.

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment