【问题标题】:Sitecore custom ribbon button not workingSitecore 自定义功能区按钮不起作用
【发布时间】:2016-12-12 06:08:06
【问题描述】:

我按照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 初始版本。

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

【问题讨论】:

  • 您能否确认您是否将contenteditor:translatecontent 放在 Sitecore 内按钮的单击字段中?

标签: sitecore sitecore8 sitecore8.2


【解决方案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)添加到您创建的按钮项的布局中。

  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/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-20
    相关资源
    最近更新 更多