我按照http://jondjones.com/how-to-add-a-custom-sitecore-button-to-the-editor-ribbon/
中提到的步骤创建了自定义功能区按钮我可以看到sitecore中出现的按钮:
单击按钮时不会触发命令。
以下是我的代码:
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 :(得分:1)
在Sitecore 8中,它更改了添加功能区按钮的方式。到目前为止,我看到您的链接来自Sitecore 7或6.
为体验编辑器功能区创建新按钮项:
在Core数据库中,打开内容编辑器并导航到/ sitecore / content / Applications / WebEdit / Ribbons / WebEdit / Page Editor / Edit。
根据相关功能区控件模板创建新项目,例如小按钮模板。模板位于/ sitecore / templates / System / Ribbon /.
对于新项目,请添加以下信息:
在标题字段中,输入按钮的显示名称。
在ID字段中,输入项目的唯一标识符。例如,您可以在ID中包含功能区组名称。
在“图标”字段中,输入相关图标的路径。根据您创建的按钮,相应地调整图标大小。
输入呈现的唯一ID。
对于其他SPEAK控件,您可以指向“数据源”字段中的另一个项目,并在此其他项目中指定配置。 重要
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/