sitecoresitecore8sitecore8.2

Sitecore custom ribbon button not working


I have created a custom ribbon button following the steps mentioned in http://jondjones.com/how-to-add-a-custom-sitecore-button-to-the-editor-ribbon/

I can see the button appearing in sitecore:

Custom button

Command does not get triggered when clicked on the button.

Below is my code:

using System;
using Sitecore.Shell.Applications.Dialogs.ProgressBoxes;
using Sitecore.Shell.Framework.Commands;

namespace SitecoreVsPoc.Commands
{
    public class TranslateContent : Command
    {
        private static readonly object Monitor = new object();
        public override void Execute(CommandContext context)
        {
            if (context == null)
                return;
            try
            {
                ProgressBox.Execute("Arjun", "Title", "Applications/32x32/refresh.png", Refresh);
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error("Error!", ex, this);
            }
        }
        public void Refresh(params object[] parameters)
        {
            // Do Stuff
        }
    }
}

Below is the command I have registered in commands.config:

<command name="contenteditor:translatecontent" type="SitecoreVsPoc.Commands.TranslateContent,SitecoreVsPoc" />

Note: I am using Sitecore 8.2 initial release.

Can someone suggest a solution for this?


Solution

  • In Sitecore 8 it was changed the way you add Ribbon button. As far I see your link is from Sitecore 7 or 6.

    To create the new button item for the Experience Editor ribbon:

    1. In the Core database, open the Content Editor and navigate to /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit.

    2. Create a new item based on the relevant ribbon control template, for example, the Small Button template. The templates are located at /sitecore/templates/System/Ribbon/.

    3. For the new item, add the following information:

      In the Header field, enter the display name of the button.

      In the ID field, enter a unique identifier for the item. For example, you can include the ribbon group name in the ID.

      In the Icon field, enter the path to the relevant icon. Depending on the button you create, adjust the icon size accordingly.

    4. Open Sitecore Rocks and add the relevant control rendering, for example SmallButton, to the layout of the button item you created. enter image description here

    5. Enter a unique ID for the rendering.

    6. For other SPEAK controls, you can point to another item in the Data Source field and specify the configuration in this other item. Important

      More informations you can find here: https://doc.sitecore.net/sitecore_experience_platform/content_authoring/the_editing_tools/the_experience_editor/customize_the_experience_editor_ribbon

      http://reyrahadian.com/2015/04/15/sitecore-8-adding-edit-meta-data-button-in-experience-editor/

      Before it was very simple, you didn't need to add new code:

      https://blog.istern.dk/2012/05/21/running-sitecore-field-editor-from-a-command/