Custom File and Folder Types

From OpenCms Wiki
Jump to: navigation, search

OpenCms offers an extension mechanism for creating new Resource Types inside of the Virtual File System.

A resource type consists of two parts, a resource type class and configuration data.

Resource Type Class

The resource type class implements the functionality of a new resource type. This class has to be derived from the abstract class org.opencms.file.types.A_CmsResourceType.

Configuration Data

Opencms needs to know that your resource type exists. There are several ways to do this.

The easiest approach is to add a resource type definition to /WEB-INF/config/opencms-vfs.xml. A drawback of this approach is that you cannot easily transfer the definition to another OpenCms server. You would have to do the same change to the other server's configuration file.

The cleaner approach is to create a module. A module can be exported with its complete configuration on one server and imported on another server. After your module has been created, you need to edit the configuration to add the resource type definition.

The configuration of all installed modules is contained in in the file /WEB-INF/config/opencms-modules.xml in the Real File System. Whereas many properties of your module can be edited from the opencms workplace, the settings for resource types can be only changed directly in this XML configuration file. Here you could also group your own resource types in subsections of the "new"-dialogue by defining a special explorertype.

A full installation of OpenCms already comes with several resource types and some of these are brought into the systems via a module. Therefore, in opencms-modules.xml you can find good examples, that show how to set the basic technical properties and the context menu behavior of your new resource type.

The following thread from the opencms-dev mailing list has more information: [1]

A third approach to configure the resource type is to put the definition into the module's manifest.xml. To do this, you first have to export your module after it has been created and add the resource type definition to the element /export/module/resourcetypes. However, this approach is least documented and the manifest.xml format is, as export as the name of its root element suggests, not actually thought for configuration of the module but more for module exchange. There are no tools to create such a manifest file.

Caveats

Be careful to use a new, unique ID for your resource types. This ID must be identical between your resource class and your module configuration and the number should be high enough to be far away from the standard resource types that are delivered with OpenCms.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox