【问题标题】:How to enable the button which is created using custom control如何启用使用自定义控件创建的按钮
【发布时间】:2012-08-10 07:35:37
【问题描述】:

我需要在 tridion 功能区中创建一个在另一个下方的按钮。

我创建了一个用户控件,它出现在功能区上,但处于禁用模式。 在“http://tridiondeveloper.com/ribbon-item-group”;有人提到在配置中的我的扩展元素中包含<ext:issmallbutton>true</ext:issmallbutton>。我已将它包含在 extension.config 文件中。但是我遇到了类似“加载扩展失败 - 有无效的子元素'issmallbutton'的错误。所以,目前我忽略了这一步,按钮处于禁用模式。

能否请您让我了解我需要在哪里添加这个(<ext:issmallbutton>true</ext:issmallbutton>)并启用按钮。

【问题讨论】:

  • 很高兴看到有人从事这种类型的设置工作,但在这个问题上 -1 因为错过了使用<ext:issmallbutton> 的文章关于 not 的观点并跳过了@ 中的步骤987654324@ 展示了如何验证配置文件并获取要显示的按钮。不过,您的其他问题和已接受的答案正在显示进展,祝您好运并不断提出问题。

标签: tridion tridion-2011


【解决方案1】:

正如 Jeremy 的回答所表明的,您不需要 ext:issmallbutton 来启用您的按钮(您在 Tridion Developer 上提到了 my article,我在其中特别声明当您想要使用 ext:issmallbutton 时不要使用将按钮堆叠在一起)。

您可能应该尝试调试您的 JavaScript 并查看您的 _isAvailable(selection, pipeline)_isEnabled(selection, pipeline) 方法中发生了什么。

isAvailable 方法应该指示该命令是否适用于所选项目,isEnabled 方法应该指示该命令是否可以执行。我通常只是让 isEnabled 方法返回 isAvailable 的结果(因为当按钮可用时,它应该大部分时间也被启用)。选择页面后如何启用按钮的示例如下所示:

Example.PageBtn.prototype._isAvailable = function PageBtn$_isAvailable(selection, pipeline) {
    if (pipeline) {
        pipeline.stop = false;
    }

    if (selection.getCount() == 1) {
        var itemType = $models.getItemType(selection.getItem(0));
        return itemType && (itemType == $const.ItemType.PAGE);
    }
    return false;
};
Example.PageBtn.prototype._isEnabled = function PageBtn$_isEnabled(selection, pipeline) {
    if (pipeline) {
        pipeline.stop = false;
    }
    return this._isAvailable(selection);
}; 

现在ext:issmallbutton 元素与这一切无关,但如果您想知道应该在哪里使用它,它应该像这样进入ext:extension元素内部:

<ext:extension assignid="PageBtn" groupid="MyGroup" name="Example" pageid="HomePage">
    <ext:command>PageBtn</ext:command>
    <ext:title>Example</ext:title>
    <ext:issmallbutton>true</ext:issmallbutton>
    <ext:dependencies>
        <cfg:dependency>Example.Commands</cfg:dependency>
    </ext:dependencies>
    <ext:apply>
        <ext:view name="DashboardView">
            <ext:control id="DashboardToolbar" />
        </ext:view>
    </ext:apply>
</ext:extension>

您可以在Setting up a SDL Tridion 2011 GUI extension in 8 steps找到更多信息。

【讨论】:

  • 感谢巴特的解释。在按钮以禁用状态出现后,在 Mozilla firebug 的帮助下,我发现类正在应用于按钮:class= tridion button custombtn ribbonitem smallbutton disabled。我没有写这个。
  • 如果按钮被禁用,您的 _isEnabled 方法没有触发或者没有返回 true。通过查看提供的示例重新开始,当你有这些示例时,然后继续下一步以获取你的特定功能,而不是相反。
  • 创建的用户控件,我只是将扩展名.config、.js 放在一起,并在我的 .js 文件中引用 ascx。我需要将我的用户控件放在任何其他文件夹中吗?
【解决方案2】:

要启用按钮,您需要其 isEnabled 方法返回 true。 issmallbutton 仅确定工具栏中按钮的大小。有关如何创建按钮扩展的信息,请查看关于同一主题的许多其他问题...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-05
    • 1970-01-01
    相关资源
    最近更新 更多