Sitecore Page Editor - How to Extend the Page Editor Toolbar

You need to add the β€œpublish” function to the page editor, section editing element. (In the Advanced section, it would be ideal). How can i do this?

enter image description here

+4
source share
2 answers

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).
+10
source

We can achieve this without changing the code.

 <command name="webedit:publish" type="Sitecore.Shell.Framework.Commands.PublishItem,Sitecore.Kernel" /> 

Add the above entry to the Commands.config file. This file is available in the include folder.

  • Login to Sitecore Desktop
  • Switching the database to the kernel
  • Duplicate / sitecore / content / Applications / WebEdit / General field buttons / Edit related item
  • Rename a new item to publish the associated item
  • Set the Click property of this element to chrome: common: edititem ({command: "webedit: publish"})
  • Switch database back to main
  • Open the page editor and test the new command (it should open a standard publication popup with the corresponding element identifier as a parameter in the URL).

thanks

Fenil

+2
source

Source: https://habr.com/ru/post/1498124/


All Articles