Override a Core Content Type

A number of content types are included with the Widget Framework (Story and Picture, for example). These core content types are designed both to work well with the Widget Framework and to provide a flexible "starter pack" of content types that will support a wide range of publication types. Although the core content types satisfy most standard requirements, you may nevertheless feel the need to modify or extend one or more of them in some way.

Should you need modify a core content type, it is actually quite simple to do so. What you actually do is to override the content type within a specific publication: you copy the content type definition from the Widget Framework distribution into your publication's content-type resource, make the changes you require and then build and upload your publication to the Content Engine in the usual way. During the build process, the content type definitions are merged in such a way that your modified version overrides the standard version supplied with the Widget Framework.

The following procedure describes how to change a content type definition for the demo publication supplied with the Widget Framework. The process is, however, exactly the same for any other publication.

  1. Unzip the Widget Framework distribution file widget-framework-core-4.0.3-1.zip somewhere on you computer.

  2. In the misc/widgets/widget-framework-core/src/main/webapp/META-INF/escenic/publication-resources/escenic/ of the unzipped folder tree you will find a content-type resource file. Open this file in an editor.

  3. Find the content type definition you want to change (let's say the story content type).

  4. Copy the content type definition.

  5. In the misc/demo/src/main/webapp/META-INF/escenic/publication-resources/escenic folder of the unzipped folder tree you will find another content-type resource file. Open this file in an editor and paste in the copied content type definition.

  6. Make whatever changes you require to the pasted content type definition. You might, for example, add a field to it.

  7. Save your changes and close both content-type files.

  8. In the misc/demo/demo-site folder, enter:

    $ mvn clean install

    This will produce a publication .war file in misc/demo/demo-site/target called demo-core-4.0.3-1.war.

  9. Use the escenic-admin webapp to create a publication from the .war file you have generated or upload it to an existing publication.

  10. Open the publication you have created/modified in Content Studio and create a story content item. You should be able to see the change you have made.

Note the following points:

  • You only need to copy and modify the specific elements you want to change. Even though the story content type references lots of fields and field groups defined elsewhere in the content-type resource, you don't have to copy them as well. The file you copy into does not need to be a complete content-type resource because it's just a collection of overrides that are merged with the main content-type resource during the build process.

  • You don't need to copy entire content type definitions either. If for example, you just want to add some constraints to a field definition, then you only need to copy the field-group the field belongs to, and modify the required field. Don't copy individual field elements though, since they don't have unique names and therefore cannot be merged correctly.