简体   繁体   English

如何在SDL Tridion 2011 SP1中扩展“CheckOut”命令?

[英]How to Extend “CheckOut” Command in SDL Tridion 2011 SP1?

I am trying to extend the "CheckOut" command of Tridion, and as of now I am trying to display my own message and am expecting the OOTB CheckOut action needs to be place when i click "CheckOut" option from the ribbon tool bar. 我正在尝试扩展Tridion的“CheckOut”命令,截至目前我正在尝试显示我自己的消息,并且当我单击功能区工具栏中的“CheckOut”选项时,我希望OOTB CheckOut操作需要放置。

I have created the config file and .js file as given below, i have made changes in the System.config as well and created the virtual directory also. 我已经创建了配置文件和.js文件,如下所示,我也在System.config中进行了更改,并创建了虚拟目录。 However my .js not fired and not displaying my custom message. 但是我的.js没有被解雇,也没有显示我的自定义消息。

config.xml config.xml中

<?xml version="1.0"?>
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge" xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration" xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions" xmlns:cmenu="http://www.sdltridion.com/2009/GUI/extensions/ContextMenu">
<resources cache="true">
    <cfg:filters/>
    <cfg:groups>
        <cfg:group name="CommandsExtensions.Commandset" merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor" merge="always">
            <cfg:fileset>
                <cfg:file type="script">/js/ExtendCheckOut.js</cfg:file>
                <cfg:file type="reference">CommandsExtensions.Interface</cfg:file>
            </cfg:fileset>
            <cfg:dependencies>
                <cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
                <cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
            </cfg:dependencies>
        </cfg:group>
    </cfg:groups>
</resources>
<definitionfiles/>
<extensions>
    <ext:editorextensions>
        <ext:editorextension target="CME">
            <ext:editurls/>
            <ext:listdefinitions/>
            <ext:taskbars/>
            <ext:commands/>
            <ext:commandextensions>
                <ext:commands>
                    <ext:command name="CheckOut" extendingcommand="ExtendCheckOut" />
                </ext:commands>
                <ext:dependencies>
                    <cfg:dependency>CommandsExtensions.Commandset</cfg:dependency>
                </ext:dependencies>
            </ext:commandextensions>
            <ext:contextmenus/>
            <ext:lists/>
            <ext:tabpages/>
            <ext:toolbars/>
            <ext:ribbontoolbars/>
        </ext:editorextension>
    </ext:editorextensions>
    <ext:dataextenders/>
</extensions>
<commands>
    <cfg:commandset id="CommandsExtensions.Interface">
        <cfg:command name="ExtendCheckOut" implementation="CommandsExtensions.ExtendCheckOut"/>
    </cfg:commandset>
</commands>
<contextmenus/>
<localization/>
<settings>
    <defaultpage>/Views/Default.aspx</defaultpage>
    <navigatorurl>/Views/Default.aspx</navigatorurl>
    <editurls/>
    <listdefinitions/>
    <itemicons/>
    <theme>
        <path>css</path>
    </theme>
    <customconfiguration/>
</settings>

.js file .js文件

Type.registerNamespace("Extensions");

Extensions.ExtendCheckOut = function Extensions.ExtendCheckOut() {
   Type.enableInterface(this, "Extensions.ExtendCheckOut");
   this.addInterface("Tridion.Cme.Command", ["ExtendCheckOut"]);
};

Extensions.ExtendCheckOut.prototype.isAvailable = function ExtendCheckOut$isAvailable(selection) {
   return true;
}

Extensions.ExtendCheckOut.prototype.isEnabled = function ExtendCheckOut$isEnabled(selection) {
   return true;
}

Extensions.ExtendCheckOut.prototype._execute = function ExtendCheckOut$_execute(selection) {
   $messages.registerWarning("This is Extended CheckOut");
}

This is what I did, extending the Save button: 这就是我做的,扩展了Save按钮:

<cfg:groups>
  <cfg:group name="ValidateTitleField.CommandSet">
    <cfg:fileset>
      <cfg:file type="script">/Commands/ValidateTitleFieldCommand.js</cfg:file>
      <cfg:file type="reference">ValidateTitleField.Interface</cfg:file>
    </cfg:fileset>
    <cfg:dependencies>
      <cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
      <cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
    </cfg:dependencies>
  </cfg:group>
  <cfg:group name="ValidateTitleField.Views.ValidateTitleFieldPopup">
    <cfg:fileset>
      <cfg:file type="script">/Views/ValidateTitleFieldPopup.js</cfg:file>
      <cfg:file type="style">/Views/ValidateTitleFieldPopup.css</cfg:file>
    </cfg:fileset>
    <cfg:dependencies>
      <cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
      <cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
    </cfg:dependencies>
  </cfg:group>
</cfg:groups>

[...] [...]

  <ext:editorextension target="CME">
    <ext:editurls />
    <ext:listdefinitions />
    <ext:taskbars />
    <ext:commands />
    <ext:commandextensions>
      <ext:commands>
        <ext:command name="Save" extendingcommand="ValidateTitleField"/>
      </ext:commands>
      <ext:dependencies>
        <cfg:dependency>ValidateTitleField.CommandSet</cfg:dependency>
      </ext:dependencies>
    </ext:commandextensions>
    <ext:contextmenus />
    <ext:lists />
    <ext:tabpages />
    <ext:toolbars />
    <ext:ribbontoolbars />
  </ext:editorextension>

[...] [...]

<commands>
  <cfg:commandset id="ValidateTitleField.Interface">
    <cfg:command name="ValidateTitleField" implementation="Company.Extensions.ValidateTitleFieldCommand"/>
  </cfg:commandset>
</commands>

Then in my command implementation (JS) I used the following to invoke the "original" methods: 然后在我的命令实现(JS)中,我使用以下方法来调用“原始”方法:

Company.Extensions.ValidateTitleFieldCommand.prototype._isAvailable = function ValidateTitleFieldCommand$_isAvailable(selection) {
    console.debug("Is Available called");
    return $cme.getCommand("Save")._isAvailable(selection);
};

And finally, somewhere deep in the _execute method: 最后,在_execute方法的深处:

if (!failed)
    return $cme.getCommand("Save")._execute(selection, pipeline);
else {
    this.loadPopup();
}

Hope this helps, 希望这可以帮助,

N ñ

You have a mismatch between the implementation your configuration file points to: 您的配置文件指向的implementation与之间不匹配:

<commands>
    <cfg:commandset id="CommandsExtensions.Interface">
        <cfg:command name="ExtendCheckOut" 
                     implementation="CommandsExtensions.ExtendCheckOut"/>
    </cfg:commandset>
</commands>

And the actual JavaScript code: 和实际的JavaScript代码:

Extensions.ExtendCheckOut = function Extensions.ExtendCheckOut() {

You'll probably want to change the configuration file to: 您可能希望将配置文件更改为:

        <cfg:command name="ExtendCheckOut" 
                     implementation="Extensions.ExtendCheckOut"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM