Sitecore 自定义功能区按钮不起作用
Sitecore custom ribbon button not working
我按照 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 初始版本。
有人可以为此提出解决方案吗?
在 Sitecore 8 中,添加功能区按钮的方式发生了变化。据我所知,您的 link 来自 Sitecore 7 或 6。
为体验编辑器功能区创建新按钮项目:
在核心数据库中,打开内容编辑器并导航至 /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit。
根据相关的功能区控件模板创建一个新项,例如小按钮模板。模板位于 /sitecore/templates/System/Ribbon/.
对于新项目,添加以下信息:
在页眉字段中,输入按钮的显示名称。
在 ID 字段中,输入项目的唯一标识符。例如,您可以在 ID 中包含色带组名称。
在“图标”字段中,输入相关图标的路径。根据您创建的按钮,相应地调整图标大小。
打开 Sitecore Rocks 并将相关控件渲染(例如 SmallButton)添加到您创建的按钮项的布局中。
为渲染输入唯一 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/
我按照 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 初始版本。
有人可以为此提出解决方案吗?
在 Sitecore 8 中,添加功能区按钮的方式发生了变化。据我所知,您的 link 来自 Sitecore 7 或 6。
为体验编辑器功能区创建新按钮项目:
在核心数据库中,打开内容编辑器并导航至 /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit。
根据相关的功能区控件模板创建一个新项,例如小按钮模板。模板位于 /sitecore/templates/System/Ribbon/.
对于新项目,添加以下信息:
在页眉字段中,输入按钮的显示名称。
在 ID 字段中,输入项目的唯一标识符。例如,您可以在 ID 中包含色带组名称。
在“图标”字段中,输入相关图标的路径。根据您创建的按钮,相应地调整图标大小。
打开 Sitecore Rocks 并将相关控件渲染(例如 SmallButton)添加到您创建的按钮项的布局中。
为渲染输入唯一 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/