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

谁说胖子不能爱 提交于 2019-12-04 03:47:15

问题


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


回答1:


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).



回答2:


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



来源:https://stackoverflow.com/questions/18350587/sitecore-page-editor-how-to-extend-page-editor-item-editing-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!