How to add Recycle Bin button to sitecore ribbon?

Friends, this is tidbit thing about sitecore. Sitecore newbie who wants to know how to add new command in ribbon (in sitecore- we call button as “command”) will find this post useful. Scenario: Have you ever imagined from where all sitecore buttons are coming? Do you want to create your own sitecore command/button? If so, then after reading this post you will be able to achieve it. Reason: Sometimes you want to add your own command in sitecore to introduce new feature or may be you want to replicate existing command to new location, in such case you can take advantage of sitecore flexible architecture to hook your own logic. How to achieve it?  Today we will take example of existing sitecore command (you know “command” means “button” in sitecore). Do you know where is “RecycleBin” command in sitecore content editor? Can’t find in ribbon? Well, it is in sitecore menu. Here it is:

Whenever you want to see deleted items of sitecore, you need to click on “sitecore” button and then select “Recycle Bin” – two clicks.. huh.. What if this can be achieved by one click? What if you can set “Recycle Bin” button in ribbon? This may increase your efficiency. How about this?

Like it?  Then let’s see how to configure it in your environment? It’s very simple and that is what I like most about sitecore. One of the best things about sitecore is it is fully customizable. You can hook your logic anywhere in sitecore. In upcoming posts, we are going to see couple of customization and I am sure you will also like it. Here are steps: 1) Switch to “core” database 2) Go to “/sitecore/content/Applications/Content Editor/Ribbons/Chunks/Operations” path 3) Add a new item of type “/sitecore/templates/System/Ribbon/Large Button”, give any name to this item (for example: “Recycle Bin”) 4) Add “click” action as “item:recyclebin” and set other parameter as per your choice. Refer below screen-shot for more details:

 5) Now let’s add code for “item:recyclebin” command. To add this code, we need to create a new command by inheriting from sitecore’s command class.

 public class RecycleBinCommand: Command     {         public override void Execute(CommandContext context)         {             Assert.ArgumentNotNull(context, "context");             Windows.RunApplication("Archives/Recycle Bin", "");         }     }  

 If you want to look at how my visual studio solution explorer after adding this new command, then here you go:

  6) The last step is to add above “RecycleBinCommand” in commands.config file. Here we will tell sitecore that “item:recyclebin” should call “RecycleBinCommand” class.


 That’s it, you are about to go. Click on RecycleBin button and you should see dialog box like this:

Thanks to my colleague Azamat for reviewing my first draft of this post. Customize sitecore, increase your efficiency !!!

2 Responses to “How to add Recycle Bin button to sitecore ribbon?”
  1. Shubh August 26, 2014
  2. Nilesh Thakkar September 1, 2014

Leave a Reply