Written by The Jahia Team
   Estimated reading time:

Abstract Type

Mixins are abstract data types that are packaged with a set of related properties.   

Occasionally, mixins are used as flags rather than property packages.  

Example of a Mixin declaration:

[jmix:mixin-name] mixin
- properties
+ child

Example of using a Mixin as part of a component definittion:

[jnt:content-type] > jnt:content, mixin1, mixin2

Due to the inheritance mechanism, parent properties can be retrieved as well.

Only a single parent node type is allowed, but several parent mixins can be set.

How NodeTypes become Components

To make the node type available for editors, a Mixin is selected from the following list:

jmix:basicContent
jmix:structuredContent
jmix:multimediaContent
jmix:listContent
jmix:formContent
jmix:queryContent
jmix:siteComponent
jmix:socialComponent
jmix:layoutComponentContent

By applying one of theses mixins, a node type will appear in the components list, and editors will be able to drag and drop the component on the page . This is also how component categories are added:

[mymix:myContent] > jmix:droppableContent mixin

Example of adding this new Mixin to a Component

<jnt = 'http://www.jahia.org/jahia/nt/1.0'>
<jmix = 'http://www.jahia.org/jahia/mix/1.0'>
<acme = 'http://www.acme.com/jahia/nt/1.0'>
<acmemix = 'http://www.acme.com/jahia/mix/1.0'>


[acmemix:acmeComponent] > jmix:droppableContent mixin

[acme:newsItem] > jnt:content, acme:acmeComponent 
- title (string)
- body (string)
- date (date)
- breakingNews (boolean)

Creating a Mixin Node Type

  1. Under definitions.cnd the "New node type definition" option is selected.
  2. ”Mixin node type” is selected from the resulting pop-up window.

new-node-type-mixin.png

Refer below for an example of creating the Mixin type called "My Content Category". Note that it inherits from the Mixin jmix:droppableContent.

mixin-example-mycategory.png

Using mix:title

The predefined mixin mix:title is used to define a standardized title, on which the system name is synchronized:

[mix:title]  mixin  
        - jcr:title (string) i18n boost=2.0

This Mixin can be used on any content type.

Note, the following content type has two properties: one is jcr:title, and the other one is text.

[mynt:myComponent] > jnt:content, mynt:myCategory, mix:title
        - text (string, richtext)

If the default inherited property configuration does not fit the component requirements, then it can be overridden:

[mynt:myComponent] > jnt:content, mynt:myCategory, mix:title
        - jcr:title (string) primary
        - text (string, richtext) i18n

Note that this content type has only one jcr:title property, which is not internationalized due to being overriden. 

Academy Document: Content Types

Further reading on Components and Content Types:

Creating a Content Type

Exercise: Create a new Mixin for 'Component Category'

  1. Add a property 'Badge Number', of type string, to the employee component.
    • Synchronize the system name with this property.
  2. Add a property to the employee component called “biography” of type string.
  3. Create a custom component category for components created in the AcmeCompany Module.  
  4. Switch the Employee component from the category “Content: structured” to this custom component category.