-2

I need to create buttons one below the other in tridion ribbon.

I have created an usercontrol and it was appearing on the ribbon but in disabled mode. In the "http://tridiondeveloper.com/ribbon-item-group"; it was mentioned to include <ext:issmallbutton>true</ext:issmallbutton> inside my extension element in the configuration. I have included it in the extension.config file. But i am facing error like "Loading extension failed - has invalid child element 'issmallbutton'. So, currently i ignored this step and the buttons were in disabled mode.

Could you please let me understand where i need to add this.(<ext:issmallbutton>true</ext:issmallbutton> ) and to make the buttons enable.

pavan
  • 451
  • 1
  • 5
  • 16
  • Nice to see someone working on this type of setup, but -1 on this question for missing the article's point on *not* using `` and for skipping the steps in `Setting up a SDL Tridion 2011 GUI extension in 8 steps` which shows how to validate the config file and get buttons to show. Your other questions and accepted answers are showing progress though, good luck and keep the questions coming. – Alvin Reyes Aug 13 '12 at 14:54

2 Answers2

5

As indicated by Jeremy's answer, you don't need the ext:issmallbutton to enable your button (you mention my article on Tridion Developer, where I specifically state that the ext:issmallbutton is not to be used when you want to stack buttons on top of eachother).

You probably should try to debug your JavaScript and see what is happening in your _isAvailable(selection, pipeline) and _isEnabled(selection, pipeline) methods.

The isAvailable method should indicate whether the command is applicable for the selected item(s) and the isEnabled method indicates whether the command can be executed. I usually just let the isEnabled method return the result of the isAvailable one (since when the button is available, it should most of the time also be enabled). An example of how to enable a button when you have selected a Page would look something like this:

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);
}; 

Now the ext:issmallbutton element has nothing to do with this all, but if you would like to know where that should be used exactly, it is supposed to go inside the ext:extensionelement like so:

<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>

You can find more information in Setting up a SDL Tridion 2011 GUI extension in 8 steps.

Bart Koopman
  • 4,835
  • 17
  • 30
  • Thanks Bart for your explation. After the buttons were appearing in the disabled state,with the help of Mozilla firebug i find class is getting applied to the button as : `class= tridion button custombtn ribbonitem smallbutton disabled`. I have not written this. – pavan Aug 10 '12 at 11:07
  • If the button is disabled, your _isEnabled method did not fire or it did not return true. Start again by looking at the examples supplied and when you have those working, then proceed to the next step of getting your specific functionality in, not the other way around. – Bart Koopman Aug 10 '12 at 11:08
  • The usercontrol created, I am just placing along with the extension.config, .js and refering to ascx in my .js file. Do i need to place my usercontrol in any of the other folders? – pavan Aug 10 '12 at 15:11
4

To enable a button you need its isEnabled method to return true. issmallbutton only determines the size of the button in the toolbar. For information on how to create a button extension please look at the many other questions on this same subject...

Jeremy Grand-Scrutton
  • 2,802
  • 14
  • 20