体验编辑器按钮的内容编辑器按钮背后的代码
Code behind Content editor button for Experience editor button
是否可以使用内容编辑器中用于功能区按钮的命令的代码隐藏作为对体验编辑器按钮的请求?我们想坚持 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
,或者有没有办法使用我们现有的代码?
您是否看过这篇关于向 Sitecore 8 体验编辑器添加自定义 SPEAK 命令按钮的博客 post?
否则,如果这没有达到您的要求,可能值得尝试使用标准 SPEAK 应用程序触发按钮的方式,在 SPEAK 应用程序中,您可以通过单击按钮调用 JavaScript 函数使用此代码。
javascript:app.FunctionName();
在核心数据库中,更新按钮上的点击字段以使用 javascript: 前缀调用 JavaScript。这会让你触发你的 JavaScript 吗?
我能够根据以下指南使用我现有的控件:
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();
}
}
);
}
};
});
是否可以使用内容编辑器中用于功能区按钮的命令的代码隐藏作为对体验编辑器按钮的请求?我们想坚持 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
,或者有没有办法使用我们现有的代码?
您是否看过这篇关于向 Sitecore 8 体验编辑器添加自定义 SPEAK 命令按钮的博客 post?
否则,如果这没有达到您的要求,可能值得尝试使用标准 SPEAK 应用程序触发按钮的方式,在 SPEAK 应用程序中,您可以通过单击按钮调用 JavaScript 函数使用此代码。
javascript:app.FunctionName();
在核心数据库中,更新按钮上的点击字段以使用 javascript: 前缀调用 JavaScript。这会让你触发你的 JavaScript 吗?
我能够根据以下指南使用我现有的控件:
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();
}
}
);
}
};
});