Overriding components

  Written by The Jahia Team
 
Developers
   Estimated reading time:
7.1.2.0

The customer has overridden two components of the Jahia Twitter 2.0.2 in his own module.
This solution was working before DF 7.x and OSGI bundle concept.
But this one no longer works as only the Jahia Twitter 2.0.2 is used.

Cause

The cause of the issue is the following one:

  1. The Jahia Twitter 2.0.2 module is active as the jnt:twitterWidget component is needed.
  2. The custome's module does not use the jnt:twitterWidget component but overrides the jnt:twitterFeed and jnt:twitterSearch by adding the jmix:socialComponent mixin.

Solution

To extend the node type via the extends directive in the definitions.cnd file.

Based on this example, the solution be this one:
 

[jmix:MysocialComponent] > jmix:socialComponent mixin
extends=jnt:twitterFeed

[jmix:MysocialComponent] > jmix:socialComponent mixin
extends=jnt:twitterSearch

For the existant jnt:twitterSearch and jnt:twitterFeed I suggest to use a simple script to add the mixin types like:
 

JCRNodeIteratorWrapper ni = session.getWorkspace().getQueryManager().createQuery("select * from [jnt:twitterSearch]", Query.JCR_SQL2).execute().getNodes();

while (ni.hasNext()) {
    JCRNodeWrapper next = (JCRNodeWrapper) ni.next();
    if (!next.isNodeType("jmix:socialComponent")) {
        next.addMixin("jmix:link");
        session.save();
    }
}

This script should be executed in live and default workspace. And also for the type jnt:twitterFeed