Sitecore 8 for Beginners -Adding Custom Button to Ribbon

In the Sitecore 8 for Beginners blog series,I’ll be sharing the knowledge which is basic but yet very important for developers who are learning the Sitecore.

In this blog post I’ll show how we can add our custom button to the Sitecore ribbon.

Later in the series,we will learn to create our custom SPEAK dialog(don’t worry,if you don’t know SPEAK) & bind that dialog to our custom ribbon button.

Before we move forward let’s have a look on the below image to understand these terms:
Ribbon,Tab,Strip & Chunk.

SCToolbar

SCToolbar

This is well explained by Kiran Patil here:
https://sitecorebasics.wordpress.com/2011/03/09/confused-between-stripchunktabribbon/

So after understanding the basics lets see what we will be doing in this blog post:

custom-tab in Sitecore Ribbon

New custom tab to the ribbon.

Looks exciting?Let’s start & login to the Sitecore.

SItecore 8 login

SItecore 8 Login

After successfully login,we can see the Sitecore 8 has Windows 8 like icons.Click the desktop icon as shown in the below image.

desktop view

Open the desktop view

Since we are adding our custom button to the shell website(the one we just logged in) & most of the settings/configuration related to the Sitecore is defined in core database,lets switch to the Core database.
Click the database icon from the bottom-right of the Sitecore’s Start Menu & select the core.

Switch to the core datbase

Switch to the core datbase

The default Sitecore ribbon items are defined under
“/sitecore/content/Applications/Content Editor/Ribbons/Ribbons/Default”
path.
Let’s add a new reference item & name it “My Custom Tab”.
If you noticed our newly created tab item (My Custom Tab) has a field called “Reference”,where we refer the “Strip” item for this tab.

My custom tab item

My custom tab item

After creating the new tab,it’s time to create the “Strip” for this tab under
“/sitecore/content/Applications/Content Editor/Ribbons/Strips”.
This new “Strip” item will have one child item which will refer the “Chunk”.

Strip Item

Strip Item

The Strip item has a field ‘Header’,which is the name shown on the ribbon

Strip Item

Strip Item

The “Chunks” are nothing but the way of separating the ribbon controls(lets call them buttons for now) as per there operation.
To understand it lets see the “Publish” tab in the ribbon.
The “Publish” tab has following chunks as shown in the image:

Sitecore ribbon

Sitecore ribbon

The display name of the chunks are “Restrictions”,”Publish” & “Social”.
As we can see each chuck has different buttons to perform different actions.

So after understanding the “Chunk” lets creates the one for our Strip under following path:
“/sitecore/content/Applications/Content Editor/Ribbons/Chunks”
Every Chunk has some buttons to perform the operation as we saw in the Publish tab’s example.
We need a button under our Chunk which will be used to launch the SPEAK dialog(in later post),so lets creates it(I used “/sitecore/templates/System/Ribbon/Large Button” template & named it “Launch My Dialog”).

my-chunk-button

My Chunk Button

Too much exercises? Let’s review what we have done so far:

  1. We have created the new “Speak” tab here :
    /sitecore/content/Applications/Content Editor/Ribbons/Ribbons/Default/Speak
  2. Which refers the Strip item from :
    /sitecore/content/Applications/Content Editor/Ribbons/Strips/Custom
  3. We have also added a child under this Strip item,which refer our custom Chunk from:
    /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Custom
  4. And finally Our Chunk item has the “Launch My Dialog” button.

Does everything looks fine?Do you see this new custom tab on the ribbon?
NO?

You won’t see this newly created tab until you follow below steps:

  • Right click on the empty space on the Ribbon.
  • Select the “Custom Tab” tab.

Our custom tab should be visible now on the ribbon as follow:

custom-tab in Sitecore Ribbon

New custom tab to the ribbon.

If you can see this new Tab in the ribbon Congratulations you have done it!!!!!!!!!
In next post we will bind our button to launch a dialog(SPEAK dialog).