definitions extend mixin Developer Jahia 7.3 Jahia 8

What is the jmix:templateMixin

Question

What is the jmix:templateMixin?

Answer

If a definition inherit of the mixin jmix:templateMixin, then the extended nodeType could inherit of this mixin.

Maybe it's better to illustrate this with a quick example. Here is a header component jnt:header that could be extended with 2 mixins jmix:video and jmix:image:

[jnt:header] > jnt:content
 - type (string, choicelist[headerTypeializer,resourceBundle]) = 'image' mandatory autocreated nofulltext

[jmix:video] > jmix:templateMixin mixin
 extends = jnt:header
 - video (weakreference, picker[type='video'])  i18n mandatory < jnt:file

[jmix:image] > jmix:templateMixin mixin
 extends = jnt:header
 - image (weakreference, picker[type='image'])  i18n mandatory < jnt:file

Now we have to implement a headerTypeializer for the property type of the jnt:header

    <bean id="headerTypeializer" class="org.jahia.services.content.nodetypes.initializers.FixedListChoiceListInitializer">
        <property name="key" value="headerTypeializer"/>
        <property name="items">
            <list>                
                <bean class="org.jahia.services.content.nodetypes.initializers.ChoiceListValue">
                    <property name="displayName" value="video"/>
                    <property name="stringValue" value="video"/>
                    <property name="properties">
                        <map>
                            <entry key="addMixin" value="jmix:video"/>
                        </map>
                    </property>
                </bean>
                <bean class="org.jahia.services.content.nodetypes.initializers.ChoiceListValue">
                    <property name="displayName" value="image"/>
                    <property name="stringValue" value="image"/>
                    <property name="properties">
                        <map>
                            <entry key="addMixin" value="jmix:image"/>
                        </map>
                    </property>
                </bean>
            </list>
        </property>
    </bean>

As you can see, depending on the chosen value of the property type, the initializer will add the mixin jmix:image or the mixin jmix:video to the node.

This can only be done for mixin that inherit jmix:templateMixin.