你需要做的是在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按鈕。這是由於內容編輯器存在錯誤。
您可能會在sitecore開發者論壇sdn.sitecore.net – 2011-03-03 12:48:24
上得到更好的回覆,感謝James,我已經做好了一些事情,但我也會在那裏嘗試。 – krul 2011-03-03 19:30:16