Tcl Procedures

If you have defined an additional menu command as a Tcl script, the following steps are required to integrate this command into the Content Navigator:

  • Store your procedure as a script file in the instance-specific script/cm/serverCmds directory.

  • Make sure that the procedure is registered in the safe Tcl interpreter. You can place the corresponding Tcl command at the end of the script file. Example:

    safeInterp alias serverProcName clientProcName

    This step is only required, if the Tcl procedure is no wizard, i.e. if the value of the dialog property is false.

  • Register the menu command in the beans section of the config/contentMenu.xml file by adding a corresponding bean. Specify as the command property the client alias registered in the safe interpreter.

  • Add a reference to the created bean to the menuBar section of the config/contentMenu.xml file to integrate the menu command into the GUI. Additionally, or alternatively, you might make the command available in the toolbar by adding a reference to the bean to the toolBar section.

  • Restart the CM and the Trifork server using bin/rc.npsd restart CM trifork.

Notes on creating the script file for the menu command

When a custom command is issued that causes a Tcl procedure to be executed, the Content Manager passes the following arguments to the procedure. The arguments depend on the scope of the command that was specified in the corresponding bean by means of the selectionType property. The value of this property can be one of:

Scope Arguments
none (global) None
single (a single file) The ID of the file concerned as the only argument.
extended (any number of files) A list containing the IDs of the files concerned, as the only argument.

The procedure needs to be defined using args so that the arguments are available as a list:

proc tclProcedureName {args} {
  foreach i $args {
  }
...
}