First you need to create a class of commands. The easiest option:
using System; using Sitecore.Shell.Applications.WebEdit.Commands; using Sitecore.Shell.Framework; using Sitecore.Shell.Framework.Commands; namespace my.assembly.namespace { [Serializable] public class Publish : WebEditCommand { public override void Execute(CommandContext context) { if (context.Items.Length != 1) return; Items.Publish(context.Items[0]); } } }
Register a new command in Sitecore.config (or Commands.config ):
<configuration> <sitecore> <commands> <command name="my:publish" type="my.assembly.namespace.Publish,my.assembly"/> </commands> </sitecore> </configuration>
Then:
- Enter Sitecore Desktop
- Switch database to kernel
- Duplicate
/sitecore/content/Applications/WebEdit/Common Field Buttons/Edit related item - Rename the new item to
Publish related item - Set the
Click property of this element to my:publish - Change other properties of the element (
Header , Icon , Tooltip ) - Switch database back to master
- Open the Page Editor and test the new command (it should open a standard publication popup with the corresponding ID element as a parameter in the URL).
source share