Sitecore自定义功能区按钮不起作用

时间:2016-12-12 06:08:07

标签: sitecore sitecore8 sitecore8.2

我按照http://jondjones.com/how-to-add-a-custom-sitecore-button-to-the-editor-ribbon/

中提到的步骤创建了自定义功能区按钮

我可以看到sitecore中出现的按钮:

Custom button

单击按钮时不会触发命令。

以下是我的代码:

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
        }
    }
}

以下是我在commands.config中注册的命令:

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

注意:我使用的是Sitecore 8.2初始版本。

有人可以为此提出解决方案吗?

1 个答案:

答案 0 :(得分:1)

在Sitecore 8中,它更改了添加功能区按钮的方式。到目前为止,我看到您的链接来自Sitecore 7或6.

为体验编辑器功能区创建新按钮项:

  1. 在Core数据库中,打开内容编辑器并导航到/ sitecore / content / Applications / WebEdit / Ribbons / WebEdit / Page Editor / Edit。

  2. 根据相关功能区控件模板创建新项目,例如小按钮模板。模板位于/ sitecore / templates / System / Ribbon /.

  3. 对于新项目,请添加以下信息:

    在标题字段中,输入按钮的显示名称。

    在ID字段中,输入项目的唯一标识符。例如,您可以在ID中包含功能区组名称。

    在“图标”字段中,输入相关图标的路径。根据您创建的按钮,相应地调整图标大小。

  4. 打开Sitecore Rocks并将相关的控件渲染(例如SmallButton)添加到您创建的按钮项的布局中。  enter image description here

  5. 输入呈现的唯一ID。

  6. 对于其他SPEAK控件,您可以指向“数据源”字段中的另一个项目,并在此其他项目中指定配置。 重要

    您可以在此处找到更多信息: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/

    在它非常简单之前,您不需要添加新代码:

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