Mixins

Structures of data that are repeated in many content types, like a set of address fields, or a combobox with a standard set of values, may be defined as mixins and reused in multiple content types. The mixin definition file must be named mixin.xml and placed in the folder cms/mixins/[name]. For example, cms/mixins/us-address/mixin.xml.

<mixin>
  <display-name>U.S. Address format</display-name>
  <items>
    <form-item-set name="address">
      <label>Address</label>
      <immutable>false</immutable>
      <custom-text/>
      <help-text/>
      <occurrences minimum="0" maximum="0"/>
      <items>
        <input type="TextLine" name="addressLine">
          <label>addressLine</label>
          <occurrences minimum="0" maximum="2"/>
        </input>
        <input type="TextLine" name="city">
          <label>City</label>
          <occurrences minimum="1" maximum="1"/>
        </input>
        <input type="TextLine" name="state">
          <label>State</label>
          <occurrences minimum="0" maximum="1"/>
        </input>
        <input type="TextLine" name="zipCode">
          <label>Zip code</label>
          <occurrences minimum="0" maximum="1"/>
        </input>
      </items>
    </form-item-set>
  </items>
</mixin>

Using a mixin

Below is an example of a simple contenttype that uses the us-address mixin. Notice that the name of the mixin folder is used and not the mixin’s Display Name.

<content-type>
  <display-name>Using mixin: us-address</display-name>
  <super-type>base:structured</super-type>
  <is-abstract>false</is-abstract>
  <is-final>true</is-final>
  <is-built-in>false</is-built-in>
  <allow-child-content>true</allow-child-content>
  <form>
    <field-set name="basic">
      <label>Status</label>
      <items>
        <inline mixin="us-address"/> 
      </items>
    </field-set>
  </form>
</content-type>
inline
The mixin inputs are included with the inline element and the attribute mixin with the name of the mixin.