如何为自定义按钮触发PopupReference.js

时间:2012-08-13 05:41:56

标签: tridion tridion-2011

我已经创建了一个名为“buttonreference”的功能完备的按钮。我正在尝试创建一个具有相同功能和不同名称的不同按钮,如“TestButton”。我按照这些步骤进行了操作。

  1. 创建了一个名为Testbutton的文件夹。
  2. 为此文件夹创建虚拟目录。
  3. 在系统配置中创建编辑器。
  4. 但是当我尝试访问此按钮时,它触发了PopupReference.js,它位于buttonreference文件夹中,而不是触发PopupReference.js,它位于我的文件夹“Testbutton”中。我不知道为什么它不会触发我的js?
  5. My 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);
        }
    }
    }
    

    任何人都可以帮我找到问题。在创建新按钮时我是否缺少anystep?我需要将.dll保留在任何地方吗?

2 个答案:

答案 0 :(得分:2)

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

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

[ControlResources("RTFExtensions.TestButton")]

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

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

...

答案 1 :(得分:2)

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