2016-12-12 64 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/

相關問題