0

我创建了一个按钮,只有在打开组件时才能在工具栏中看到它。我已经编写了相同的配置和 js 文件,但问题是这个按钮显示为禁用。按钮在那里,但未启用。请帮助我,我怎样才能启用它。

已编辑

Type.registerNamespace("Extensions.Commands");

Extensions.Commands.Button = function Extensions.Commands$Button(element) {
Type.enableInterface(this, "Extensions.Commands.Button");
this.addInterface("Tridion.Cme.Command", [element]);
this.addInterface("Tridion.Cme.FaCommand", [element]);
alert('inside the pageload');
}; 

Extensions.Commands.Button.prototype._isAvailable = function Button$_isAvailable(target) {
alert('inside the available mode');
if (target.editor.getDisposed()) {
    return false;
}

return true;
};

Extensions.Commands.Button.prototype._isEnabled = function Button$_isEnabled(target) {
alert('inside the enable mode');
if (!Tridion.OO.implementsInterface(target.editor, "Tridion.FormatArea") ||     target.editor.getDisposed()) {
alert('indise if loop');
    return false;
}

return true;
};

我的配置文件是这样的

<resources cache="true">
<cfg:filters/>
<cfg:groups>
  <cfg:group name="Extensions.Commands" >
    <cfg:fileset>          
      <cfg:file type="script">/Popups/PopupReference.js</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="Extensions.Commands.Button.Commands"  merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor"   include="byreference" merge="release">
    <cfg:fileset>
      <cfg:file type="script">/Commands/Button.js</cfg:file>

      <cfg:file type="reference">Extensions.Button.CommandSet</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:contextmenus/>
    <ext:lists/>
    <ext:tabpages/>
    <ext:toolbars/>
    <ext:ribbontoolbars>
      <ext:add>
        <!-- RIBBON TAB -->
 <!-- GROUPS -->
        <ext:extension assignid="ExtensionGroup" pageid="FormatPage" name="ExtensionsName">
          <ext:group/>
          <ext:apply>
            <ext:view name="ComponentView">
              <ext:control id="ItemToolbar"/>
            </ext:view>
          </ext:apply>
        </ext:extension>

        <!-- BUTTONS -->
        <ext:extension pageid="FormatPage" groupid="ExtensionGroup" name="Button" assignid="Button">
          <ext:command>Button</ext:command>
          <ext:title>Button</ext:title>
          <ext:dependencies>
            <cfg:dependency>Extensions.Commands.Button</cfg:dependency>
          </ext:dependencies>
          <ext:apply>
            <ext:view name="ComponentView">
              <ext:control id="ItemToolbar"/>
            </ext:view>
          </ext:apply>
        </ext:extension>
      </ext:add>
    </ext:ribbontoolbars>
  </ext:editorextension>
  </ext:editorextensions>
  <ext:dataextenders/>
</extensions>            
<commands>
 <cfg:commandset id="Extensions.Commands.Button.CommandSet">
  <cfg:command name="Button" implementation="Extensions.Commands.Button"/>
  <cfg:dependencies>
<cfg:dependency>Extensions.Commands.Button</cfg:dependency>
    <cfg:dependency />
  </cfg:dependencies>
 </cfg:commandset>
 </commands>
 <contextmenus/>
 <localization/>
 <settings>
<defaultpage/>
<navigatorurl/>
<editurls/>
<listdefinitions/>
<itemicons/>
<theme>
  <path>Themes</path>
</theme>
<customconfiguration/>
 </settings>

4

2 回答 2

4

配置文件中永远不会引用资源组“Extensions.Commands.Button.Commands”。除此之外,在 Button 扩展组中,您还依赖于配置文件中不存在的“Extensions.Commands.Button”组。所以建议清理配置文件,删除不需要的依赖项等。

PS 没有必要同时继承“Tridion.Cme.Command”和“Tridion.Cme.FaCommand”,因为最后一个已经继承了第一个。

于 2012-08-03T12:58:54.763 回答
2

正如弗兰克所说,我会检查 _IsEnabled。当此方法返回 true 时,按钮将在 SDL Tridion GUI 中启用

我将通过以下方式进行调试(注意:我的 JS 调试有点老派 :))

RTFExtensions.Commands.Button.prototype._isEnabled = function Customtags$_isEnabled(target) {
if (!Tridion.OO.implementsInterface(target.editor, "Tridion.FormatArea") ||  target.editor.getDisposed()) {
    return false;
}

通过以下方式:

  • 检查 firebug 是否有任何 JS 错误
  • 在 _isEnabled 中放置警报以查看是否正在输入
  • 在 IF 语句中放置一个警报,以查看是否始终输入

一旦你让它工作,我很想知道出了什么问题,也许你可以在这里提供解决方案?

于 2012-08-02T19:50:24.763 回答