Search code examples
tridiontridion-2011

How to display the GUI Extension Button only for Folder operations?


I have created a GUI button, and i would like to enable the button when the user selects any folder only.

I have tried to give the config xml like below, but its displaying always.

          <ext:apply>                
            <ext:view name="DashboardView">
              <ext:control id="DashboardToolbar"/>
            </ext:view>
              <ext:view name="FolderView">
                  <ext:control id="ItemToolbar"/>
              </ext:view>

          </ext:apply>

Solution

  • You have to implement the isEnabled method in the Command interface with the following check, to make sure that the type of the selected element is FOLDER.

    YourEditor.YourCommand.prototype.isEnabled = 
                function YourCommand$isEnabled(selection) {
        var itemID = selection.getItem(0);
    
        if ($models.getItemType(itemID) != $const.ItemType.FOLDER) {
            return false;
        }
        else
            return true;   
    };
    
    • If you return true on the isEnabled function, the button will be enabled.
    • If you return false, the button will be disabled

    If you need further information on how to setup the extension you can refer to: