【问题标题】:Adding a Page Editor 'Save and Publish' Button添加页面编辑器“保存并发布”按钮
【发布时间】:2011-02-28 20:47:13
【问题描述】:

我想在站点页面编辑器上的“保存并关闭”按钮旁边提供另一个按钮,一旦按下该按钮就会触发保存和发布操作。 我去了核心并复制了我打算修改的“保存并关闭”按钮。

我会将此按钮称为“保存并发布”,但现在我有点好奇是否必须修改 javascript 以包含我的自定义调用(比如说javascript:scSave("myPublish:saveAndPublish")

我正在关注this 文章以连接到管道并完成操作,但不确定这是否正确。

有什么建议吗?

【问题讨论】:

  • 您可能会在 sitecore 开发者论坛 sdn.sitecore.net 上得到更好的回应
  • 谢谢詹姆斯,我已经做了一些东西,但我也会在那里尝试。

标签: .net sitecore customization sitecore6 page-editor


【解决方案1】:

您需要做的是在 App_Config/Commands.config 中定义一个自定义命令:

<command name="myPublish:saveAndPublish" 
type="YourNamespace.YourCommand, YourAssembly" />

任何自定义命令都需要继承 Sitecore.Shell.Framework.Commands.Command 并覆盖方法 public override void Execute(CommandContext context)

使用您的自定义命令调用 PublishItem 命令:

public override void Execute(CommandContext context)
{
    var publishCommand = new PublishItem();
    publishCommand.Execute(context);
}

需要注意的几点:

  • 这对我在 Firefox 中有效,但在 Chrome 中无效,在 Chrome 中未保存该项目。 scSave 使用了大量的前端 javascript,因此这似乎是 Sitecore 的 Chrome 支持的错误。
  • 奇怪的是,scSave("item:publish") 语法不起作用,但从自定义命令间接调用 PublishComand 确实有效。如果有人知道这是为什么,请发表评论!
  • scSave 仅在从 WebEditButton(/sitecore/templates/System/WebEdit/WebEdit 按钮)调用时有效,而不是功能区按钮('/sitecore/templates/System/Ribbon/Large Button' ) 或 ('/sitecore/templates/System/Ribbon/Small Button')。
  • WebEditButton 必须位于功能区层次结构的顶部('/sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Buttons')。如果它被放置在其中一个块上(例如“新建”、“编辑”等),它将不会呈现。
  • 创建 WebEditButton 时,如果要控制页面编辑器上显示的图标,则需要通过 Raw Values 设置 Data/Icon。否则,该值将保存到 Appearance/Icon,它控制内容项的图标,而不是 PageEditor 按钮。这是由于内容编辑器的错误造成的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-20
    • 2019-07-06
    • 1970-01-01
    • 2014-07-28
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 1970-01-01
    相关资源
    最近更新 更多