close

Filter

loading table of contents...

Content Server Manual / Version 2204

Table Of Contents

4.2.3 Attaching Properties to Existing Content Types

In CoreMedia CMS it is possible to define multiple content type definitions in separate files (see Section 4.2, “Creating Content Type Definitions”). At startup time the Content Server merges these files to create the complete content type hierarchy. You can use these files to alter an existing content type definition without changing the base definition file in three ways:

The first two ways are described in Section 4.2.1, “Structure of Content Type Definitions” and Section 4.2, “Creating Content Type Definitions”. In this section you will learn how to add properties to an existing content type.

In order to add properties to an existing content type a DocTypeAspect element has been introduced, that allows you to attach properties to a content type specified by the TargetType attribute. More than one DocTypeAspects might attach properties to the same target DocType, but you have to take care that no property name clashes occur. The relationship between target and aspect is therefore of the cardinality 1:n. As a limitation to ensure consistent behavior in subtypes, it is neither allowed to alter existing or inherited properties nor attach properties that are already defined in subtypes of the TargetType. To define DocTypeAspects the definition file must be valid against the coremedia-doctypes-2009.xsd schema.

Extending content types

Figure 4.2. Extending content types


Example

An abstract content type CMMedia is defined in file A. CMMedia is an abstract content type and is the root of a media document type hierarchy.

<DocType Abstract="true" Name="CMMedia" Parent="CMTeasable">
    <LinkListProperty Name="master" Max="1" LinkType="CMMedia" 
     Override="true"/>
    <XmlProperty Name="caption" 
     Grammar="coremedia-richtext-1.0"/>
    <StringProperty Name="alt" Length="128"/>
 </DocType>

The content type CMMedia is extended with a string property named "copyright" in file B. If you want to change a content type via DocTypeAspect, you have to import the content type before, using the <ImportDocType> element. Because of the DocTypeAspect semantics, the copyright property is inherited by all subtypes of CMMedia without changing their definitions.

<ImportDocType Name="CMMedia"/>
 <DocTypeAspect TargetType="CMMedia">
    <StringProperty Name="copyright" Length="128"/>
 </DocTypeAspect>

If you add an IntProperty, a StringProperty or a DateProperty to an existing content type model of a content server after the first start, be sure, that the properties sql.schema.checkColumns and sql.schema.alterTable file are set to "true".

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.