2013-08-21 101 views

回答

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. 更改其他属性(HeaderIconTooltip
  7. 切换数据库恢复到
  8. 打开页面编辑器并测试新命令(它sho打开标准发布弹出框,其中相关项目ID作为URL中的参数)。
2

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

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

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

  1. 登录到Sitecore的桌面
  2. 切换数据库核心
  3. 复制/ Sitecore的/内容/应用/ WebEdit /通用字段按钮/编辑相关的项目
  4. 重命名新项目发布相关项目
  5. 设置此项的属性为chrome:common:edititem({command:“webedit:publish”})
  6. Switch database to master
  7. Open Page Edito r并测试新命令(它应该打开标准发布弹出窗口,并将相关的项目ID作为URL中的参数)。

感谢

Fenil