2016-12-12 66 views
0

我创建了以下我可以看到按钮出现在Sitecore的在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初始版本。

有人可以提出一个解决方案吗?

+0

您可以确认是否在Sitecore中的按钮的Click字段中放置了'contenteditor:translatecontent'? – Adrian

回答

1

在Sitecore 8中,它改变了添加Ribbon按钮的方式。据我看到你的链接是从Sitecore的7或6

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

  1. 在核心数据库,打开内容编辑器,然后定位到/ Sitecore的/ content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit。

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

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

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

    在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/

相关问题