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
- 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.
- Save this file and add it to your Visual Studio solution.
- Open your Editor's configuration file in a plain-text or XML editor.
- 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.
- 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.
- 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
- 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.
Note: If you previously created a command set, you can also add this new command to it, instead of creating a separate command set for it.
- 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.
- 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).
- 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.
- 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: