Documentation Center

Implementing and configuring a command

Implement a command by creating a JavaScript file that implements your custom functionality. Such a file may call Content Manager functionality or hook into an external application. Create a resource group for your JavaScript file, a command set to name your command, and if needed, another resource group to contain your command set.

Procedure

  1. Create a JavaScript file that contains a class that executes a piece of (built-in or custom) functionality, say "MyCommand". This is your new command.
  2. Save this file and add it to your Visual Studio solution.
  3. Open your Editor's configuration file in a plain-text or XML editor.
  4. Inside the cfg:groups element, specify a resource group for this JavaScript file by creating a new cfg:group element. Set its name to, for example, MyCustomization.CommandSet.MyCommand.
  5. Inside the cfg:group element, create a cfg:fileset element, create a cfg:file element inside it with type set to script and its contents set to the name of your JavaScript file.
  6. If your JavaScript code references Content Manager Explorer functionality, then under the cfg:fileset, create a cfg:dependencies element and fill it with two cfg:dependency elements set to the following values:
    • Tridion.Web.UI.Editors.CME
    • Tridion.Web.UI.Editors.CME.Commands
  7. In the commands section, specify a new command set for your command by creating a new cfg:commandset element. Set its id to, for example, MyCustomization.MyCommand.
  8. Inside the cfg:commandset, add a cfg:command element and set its attributes as follows:
    name
    The name of the command, say MyCommand.
    implementation
    The name of the JavaScript class you implemented, say, MyJSClasses.MyCommand.
  9. Under the cfg:command element, insert a cfg:dependencies element and insert a cfg:dependency element inside it, set to the name of the resource group you created (MyCustomization.CommandSet.MyCommand in our example).
  10. If this is the first command set you have created, also create a container resource group for your command sets. In this example, we will assume a single resource group for all your command sets. Again, create a cfg:group element in your cfg:groups section and set its name to, say, AllMyCommandSets, and create a cfg:fileset element inside it.
  11. Insert a new cfg:file element in the cfg:fileset section of your resource group for all command sets. Set the type attribute of the cfg:file element to reference, and set its value to the ID of the command set you created.

Results

You have created or updated the following structure: