1

我已经创建了一个功能齐全的按钮,名为“buttonreference”。我正在尝试创建一个具有相同功能和不同名称的不同按钮,例如“TestButton”。我遵循了这些步骤。

  1. 创建了一个名为 Testbutton 的文件夹。
  2. 为此文件夹创建了虚拟目录。
  3. 在系统配置中创建编辑器。
  4. 但是当我试图访问这个按钮时,它会触发按钮引用文件夹中的 PopupReference.js,而不是触发我的文件夹“Testbutton”中的 PopupReference.js。我不知道为什么它不触发我的js?

我的 Testbutton.js 如下:

Type.registerNamespace("RTFExtensions.Commands");

RTFExtensions.Commands.TestButton = function Commands$TestButton(name) {
Type.enableInterface(this, "RTFExtensions.Commands.TestButton");
this.addInterface("Tridion.Cme.Command", [name || "TestButton"]);
this.addInterface("Tridion.Cme.FaCommand", [name || "TestButton"]);
};

RTFExtensions.Commands.TestButton.prototype._isAvailable = function     TestButton$_isAvailable(target) {
if (target.editor.getDisposed()) {
    return false;
}

return true;
};

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

return true;
};

RTFExtensions.Commands.TestButton.prototype._execute = function TestButton$_execute(target) {
if (target.item.isActivePopupOpened()) {
    return;
}

function TestButton$execute$onPopupCanceled(event) {
    target.item.closeActivePopup();
};

var url = $config.expandEditorPath("/Popups/PopupReference.aspx","TestButton");
//alert(url);
var popup = $popup.create(url,"toolbar=no,width=900,height=800,resizable=yes,scrollbars=yes", null);

$evt.addEventHandler(popup, "submit",
    function TestButton$execute$onPopupSubmitted(event) {

        alert('Inside testbuttonjs');

        // Release
        target.item.closeActivePopup();
    }
);

$evt.addEventHandler(popup, "unload", TestButton$execute$onPopupCanceled);

target.item.setActivePopup(popup);
popup.open();
};

我的 TestButton 配置文件是这样的:

<?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="RTFExtensions.TestButton">
    <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="RTFExtensions.TestButton.Commands" merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor" include="byreference"   merge="release">
    <cfg:fileset>
      <cfg:file type="script">/Commands/TestButton.js</cfg:file>

      <cfg:file     type="reference">RTFExtensions.TestButton.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="RTF Extensions">
          <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="TestButton" assignid="TestButton">
          <ext:command>TestButton</ext:command>
          <ext:title>TestButton</ext:title>
          <ext:dependencies>
                    <cfg:dependency>RTFExtensions.TestButton.Commands</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="RTFExtensions.TestButton.CommandSet">
  <cfg:command name="TestButton"    implementation="RTFExtensions.Commands.TestButton"/>
  <cfg:dependencies>
    <cfg:dependency/>
  </cfg:dependencies>
    </cfg:commandset>
</commands>
<contextmenus/>
<localization/>
<settings>
<defaultpage/>
<navigatorurl/>
<editurls/>
<listdefinitions/>
<itemicons/>
<theme>
  <path>Themes</path>
    </theme>
    <customconfiguration/>
 </settings>
</Configuration>

我的 PopupReference.Js 就像:

Type.registerNamespace("RTFExtensions.Popups");

RTFExtensions.Popups.PopupReference = function (element) {
Type.enableInterface(this, "RTFExtensions.Popups.PopupReference");
this.addInterface("Tridion.Cme.View");
};

RTFExtensions.Popups.PopupReference.prototype.initialize = function () {
$log.message("Initializing Button Reference popup...");
this.callBase("Tridion.Cme.View", "initialize");
$log.message("Initializing TestButton Reference popup...");
var p = this.properties;
var c = p.controls;

p.HtmlValue = { value: null };

c.InsertButton = $controls.getControl($("#InsertButton"), "Tridion.Controls.Button");
$evt.addEventHandler(c.InsertButton, "click", this.getDelegate(this._execute));
};

RTFExtensions.Popups.PopupReference.prototype._execute = function () {
alert('Inside Popupreferencejs');
this.fireEvent("submit", this.properties.HtmlValue);
window.close();
};

$display.registerView(RTFExtensions.Popups.PopupReference);

我的 TestButton 的 CS 页面是这样的:

namespace Tridion.GUI.Extensions.RTF.Popups
{
[ControlResourcesDependency(new Type[] { typeof(Popup), typeof(Tridion.Web.UI.Controls.Button), typeof(Stack), typeof(Dropdown), typeof(List) })]
[ControlResources("RTFExtensions.TestButton")]
public partial class PopupReference : TridionPage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        TridionManager tm = new TridionManager();

        tm.Editor = "RTFTestButton";
        System.Web.UI.HtmlControls.HtmlGenericControl dep = new System.Web.UI.HtmlControls.HtmlGenericControl("dependency");
        dep.InnerText = "Tridion.Web.UI.Editors.CME";
        tm.dependencies.Add(dep);

        System.Web.UI.HtmlControls.HtmlGenericControl dep2 = new System.Web.UI.HtmlControls.HtmlGenericControl("dependency");
        dep2.InnerText = "Tridion.Web.UI.Editors.CME.commands";
        tm.dependencies.Add(dep2);

        //Add them to the Head section
        this.Header.Controls.Add(tm); //At(0, tm);
    }
}
}

谁能帮我找到问题。创建新按钮时我错过了任何步骤吗?我需要将 .dll 保存到任何地方吗?

4

2 回答 2

2

对我来说,一切看起来都很好!

在您的 c# 中,您使用以下代码调用参考组:

[ControlResources("RTFExtensions.TestButton")]

我还看到您的配置文件包含组“RTFExtensions.TestButton”,所以一切看起来都不错。

您是否构建了 .net 项目并将 DLL 放入 [tridion_home]/web/webUI/webRoot/bin

??

于 2012-08-13T07:34:22.473 回答
2

您必须为弹出的 aspx 页面中的更新代码编译 dll。如果不是,您将使用编译代码时页面中存在的任何值。

于 2012-08-13T10:57:11.927 回答