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/Ribbon/Large Button') または ('/sitecore/templates/System) ではなく、 WebEditButton (/sitecore/templates/System/WebEdit/WebEdit Button)から呼び出された場合にのみ機能します。 /Ribbon/Small Button')。
- WebEditButton は、リボン階層の最上位に配置する必要があります ('/sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Buttons')。チャンク (「新規」、「編集」など) の 1 つに配置されている場合、レンダリングされません。
- WebEditButton を作成するときに、ページ エディターに表示されるアイコンを制御したい場合は、生の値を介してデータ/アイコンを設定する必要があります。それ以外の場合、値は、PageEditor ボタンではなく、コンテンツ アイテムのアイコンを制御する Appearance/Icon に保存されます。これは、コンテンツ エディターのバグによるものです。