2011-02-28 61 views
6

我想提供另一個按鈕旁邊的「保存&關閉」按鈕在網頁編輯器,將觸發一旦按下保存和發佈操作。 我去核心並製作了一個我打算修改的「保存&關閉」按鈕的副本。添加一個頁面編輯器的「保存併發布」按鈕

enter image description here

我會叫這個按鈕「保存&發佈」,但現在我如果我要修改JavaScript來包括我的自定義調用還挺好奇的(比方說javascript:scSave("myPublish:saveAndPublish")

我繼this文章掛鉤管道和完成行動,但不知道如果這是正確的方式。

有什麼建議嗎?

+0

您可能會在sitecore開發者論壇sdn.sitecore.net – 2011-03-03 12:48:24

+0

上得到更好的回覆,感謝James,我已經做好了一些事情,但我也會在那裏嘗試。 – krul 2011-03-03 19:30:16

回答

4

你需要做的是在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的工作,但沒有瀏覽器,在產品沒有保存。 scSave使用了很多前端JavaScript,所以這似乎是Sitecore的Chrome支持的一個缺陷。
  • 奇怪的是,語法scSave("item:publish")不起作用,但通過自定義命令間接調用PublishComand可行。如果有人知道這是爲什麼,請評論!
  • scSave只適用於從WebEditButton(/ 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時,如果要控制頁面編輯器上顯示的圖標,則需要通過原始值設置數據/圖標。否則,值將被保存到外觀/圖標,該圖標控制內容項的圖標,而不是PageEditor按鈕。這是由於內容編輯器存在錯誤。
相關問題