是否可以使用内容编辑器中用于功能区按钮的命令后面的代码作为体验编辑器按钮的请求?我们希望坚持使用SPEAK而不对Sitecore.ExperienceEditor.config
进行任何更改。
在体验编辑器中创建新按钮后,告诉.js通过
调用NewCommand
请求
Sitecore.ExperienceEditor.PipelinesUtil.generateRequestProcessor("ExperienceEditor.NewCommand");
在Sitecore.ExperienceEditor.Speak.Requests.config
中引用为
<request name="ExperienceEditor.NewCommand" type="Sitecore.Starterkit.customcode.MyCommand,MyProject"/>
没有任何反应,日志说
ERROR Could not instantiate speak request object,
name:ExperienceEditor.NewCommand,
type:Sitecore.Starterkit.customcode.MyCommand,MyProject`
我们是否必须按照某些教程的建议导入PipelineProcessorRequest
,还是有办法使用我们现有的代码?
答案 0 :(得分:0)
您是否看过有关向Sitecore 8体验编辑器添加自定义SPEAK命令按钮的博文?
否则,如果没有达到您的目的,那么可能值得尝试标准SPEAK应用程序触发按钮的方式,在SPEAK应用程序中,您可以使用此代码从按钮单击调用JavaScript函数。
javascript:app.FunctionName();
在核心数据库中更新按钮上的点击字段,使用javascript:前缀调用JavaScript。这是否允许您触发JavaScript?
答案 1 :(得分:0)
我可以使用以下指南来使用我现有的控件:
http://jockstothecore.com/sitecore-8-ribbon-button-transfiguration/
旧命令的相关部分:
if (args.IsPostBack)
{
// act upon the dialog completion
if (args.Result == "yes")
{
Context.ClientPage.SendMessage(this, "item:load(...)");
}
}
else
{
// trigger the dialog
UrlString url = new UrlString(UIUtil.GetUri("control:CopyLanguage"));
url.Add("id", item.ID.ToString());
url.Add("lang", item.Language.ToString());
url.Add("ver", item.Version.ToString());
SheerResponse.ShowModalDialog(url.ToString(), true);
args.WaitForPostBack();
}
修改后的命令:
define(["sitecore"], function (Sitecore) {
Sitecore.Commands.ScoreLanguageTools = {
canExecute: function (context) {
return true; // we will get back to this one
},
execute: function (context) {
var id = context.currentContext.itemId;
var lang = context.currentContext.language;
var ver = context.currentContext.version;
var path = "/sitecore/shell/default.aspx?xmlcontrol=CopyLanguage" +
"&id=" + id + "&lang=" + lang + "&ver=" + ver;
var features = "dialogHeight: 600px;dialogWidth: 500px;";
Sitecore.ExperienceEditor.Dialogs.showModalDialog(
path, '', features, null,
function (result) {
if (result) {
window.top.location.reload();
}
}
);
}
};
});