Sitecore page editor - how to extend page editor i

2019-02-23 17:31发布

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

2条回答
闹够了就滚
2楼-- · 2019-02-23 17:40

We can achieve it without any code change.

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

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

  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 chrome:common:edititem({command:"webedit:publish"})
  6. Switch database back to master
  7. 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).

Thanks

Fenil

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-02-23 17:41

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).
查看更多
登录 后发表回答