Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore page editor - how to extend page editor item editing panel

Need to add "publish" feature to the page editor, item editing section. (Under the "More" section would be ideal). How can I do this?

enter image description here

like image 853
Dhanuka777 Avatar asked Dec 16 '22 07:12

Dhanuka777


1 Answers

First you need to create a command class. The simplest version would be:

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 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:

  1. Login to Sitecore Desktop
  2. Switch database to core
  3. Duplicate /sitecore/content/Applications/WebEdit/Common Field Buttons/Edit related item
  4. Rename new item to Publish related item
  5. Set Click property of this item to my:publish
  6. Change other properties of the item (Header, Icon, Tooltip)
  7. Switch database back to master
  8. Open Page Editor and test the new command (it should open the standard publishing popup with the related item ID as a parameter in URL).
like image 194
Marek Musielak Avatar answered Dec 28 '22 10:12

Marek Musielak