definitions Developer Jahia 8 Jahia 7.3

Splitting the definitions.cnd file

Question

Is it possible to split a large definitions.cnd file into multiple files?

Answer

As a best practice, it is recommended to divide large modules into separate smaller modules for easier maintenance and support. However, in some cases, you may have a module with a very large definitions.cnd file.

To improve the readability and management of the file, it is possible to split it into multiple files (e.g. definitions1.cnd, definitions2.cnd, etc) within the same module and Jahia will be able to load all the definitions correctly.

 

NOTE:

When splitting a definition.cnd to multiple cnd files, all cnd files should work as a standalone cnd file. The order of the cnd files is not supported by Jahia and may depend on the file system. Sometimes it works, sometimes not.

To prevent any load issue, you could duplicate the common nodeTypes or mixin definitions in your different cnd files (it should work as a mixin is part of a bundle), but such a way is not recommended because it may be complex to maintain this code.

The only supported way would be to declare your common nodetypes or mixin in another bundle and then add a dependence to this bundle.