如何启用使用自定义控件创建的按钮

pav*_*van -2 tridion tridion-2011

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

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

你可以让我知道我需要在哪里添加这个.(<ext:issmallbutton>true</ext:issmallbutton>)并启用按钮.

Bar*_*man 5

正如Jeremy的回答所示,你不需要ext:issmallbutton启用你的按钮(你在Tridion Developer上提到我的文章,我特别声明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);
}; 
Run Code Online (Sandbox Code Playgroud)

现在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>
Run Code Online (Sandbox Code Playgroud)

您可以在8个步骤中找到有关设置SDL Tridion 2011 GUI扩展的更多信息.