4

需要在页面编辑器,项目编辑部分添加“发布”功能。(在“更多”部分下将是理想的)。我怎样才能做到这一点?

在此处输入图像描述

4

2 回答 2

10

首先,您需要创建一个命令类。最简单的版本是:

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]);
        }
    }
}

Sitecore.config在(或)中注册新命令Commands.config

<configuration> 
  <sitecore>
    <commands>
      <command name="my:publish" type="my.assembly.namespace.Publish,my.assembly"/> 
    </commands>
  </sitecore>
</configuration> 

然后:

  1. 登录Sitecore 桌面
  2. 将数据库切换到核心
  3. 复制/sitecore/content/Applications/WebEdit/Common Field Buttons/Edit related item
  4. 将新项目重命名为Publish related item
  5. Click将此项目的属性设置为my:publish
  6. 更改项目的其他属性 ( Header, Icon, Tooltip)
  7. 将数据库切换回master
  8. 打开页面编辑器并测试新命令(它应该打开标准发布弹出窗口,并将相关项目ID作为 URL 中的参数)。
于 2013-08-21T07:42:24.040 回答
2

我们可以在不更改任何代码的情况下实现它。

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

在 Commands.config 文件中添加上述条目。该文件在包含文件夹中可用。

  1. 登录 Sitecore 桌面
  2. 将数据库切换到核心
  3. 重复 /sitecore/content/Applications/WebEdit/Common Field Buttons/Edit 相关项
  4. 将新项目重命名为发布相关项目
  5. 将此项目的 Click 属性设置为 chrome:common:edititem({command:"webedit:publish"})
  6. 将数据库切换回master
  7. 打开页面编辑器并测试新命令(它应该打开标准发布弹出窗口,并将相关项目 ID 作为 URL 中的参数)。

谢谢

茴香

于 2014-09-18T09:17:47.367 回答