.net - 添加页面编辑器 'Save and Publish' 按钮

标签 .net sitecore customization sitecore6 page-editor

我想在站点页面编辑器上的“保存和关闭”按钮旁边提供另一个按钮,一旦按下,将触发保存和发布操作。
我转到核心并制作了我计划修改的“保存并关闭”按钮的副本。

enter image description here

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

我正在关注 this文章 Hook 到管道并完成操作,但不确定这是否是正确的方法。

有什么建议吗?

最佳答案

你需要做的是在 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 中无效,因为该项目未保存。 scSave 使用大量前端 javascript,因此这似乎是 Sitecore 的 Chrome 支持的错误。
  • 奇怪的是,语法 scSave("item:publish")不起作用,但从自定义命令间接调用 PublishComand 确实有效。如果有人知道这是为什么,请发表评论!
  • scSave 仅在从 调用时有效网页编辑按钮 (/sitecore/templates/System/WebEdit/WebEdit Button),而不是功能区按钮 ('/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 按钮。这是由于内容编辑器的错误造成的。
  • 关于.net - 添加页面编辑器 'Save and Publish' 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5147384/

    相关文章:

    C#语言 : Garbage Collection, SuppressFinalize

    .net - 在 Windows 8 上安装 .net 2.0 SDK

    c# - 如果文件夹包含空格,如何处理文件路径中的空格?

    c# - 有没有 BDD 的成功案例?

    Sitecore网站显示页面更新

    asp.net - 名称值列表字段未在自定义项目生成器基类中生成

    ios - 自定义 BackBarButtonItem

    css - 自定义几个GWT模块的主题

    html - Tumblr 静态页面,删除内联 CSS

    c# - 临时更改 Sitecore 项目的布局