Developer Tutorial | Create Content Types for an Existing HTML Template in Jahia (2 of 3)

Опубликовано: 19 Март 2026
на канале: Jahia
575
2

Visit https://www.jahia.com/developer-guides to learn more about developing on the Jahia Digital Experience Platform (DXP).

This is part 2 of our 3 part series on recreating an existing HTML template in the Jahia DXP. In this part, we look at how to create a Jahia module that will reflect the different content structures found in our template.

Transcript:

"Hi there! Welcome to this Jahia development tutorial.

In this tutorial we’re going to show you how to start creating content types to flesh out your Jahia digital experience - let’s get started:

This is the template we deployed on our Jahia instance in a previous tutorial. At the moment, all it’s elements are quite static; in this tutorial, we’ll show how to make this section dynamic.

We’re going to break it down into its different property elements - it’s title and description. We can see we have other similar content types across the page, so we’re going to consider all of them whilst creating this content type definitions.

For now, let’s switch back to our IDE and browse the code of the content that was just displayed. We see the same structure; the name of the section, the title, the description - we’re going to create a content type that reflects all this.

This is the first step - the second is to create a content view, which is an HTML rendering of the structure we’re about to define - we’ll cover that in the next tutorial.

The content definitions are stored in the definitions.cnd file which is created when we generate a new jahia module.

We can see we have two prefixes - dnt and dmix. Prefixes are important because they isolate the content types of one project from the others. You ensure that two teams will not define the same content type and override each other's work.

We’re going to create a definition named messageBox. It’s of type structuredContent - this type definition means that it’ll be sorted into a category within the CMS called structuredContent - there are lots of different categories in Jahia.

Here i’m describing the different fields which make up the definition of the message box content we’re creating. All the fields are of type String except for the image.

The image is actually a link to a file stored in the CMS, which we’re going to initiate through a UI picker; this means that when someone is creating a messageBox they’ll be able to select from the images they have stored on the platform.

We also have mixins - these are content types that can be inherited from other content types - if your familiar with java, think abstract.

These are useful when you have properties that are very common across content types, for example, title and description - then you can create a mixin for so your content can inherit those definitions and you won’t have to keep duplicating code.
Mixins are also very useful because they can store views; so you can very quickly & easily deploy different renderings, for example an HTML view, across your content components


Here i’m adding i18n which is shorthand for internationalization, meaning the content will be translatable to many languages.

This concludes the creating content types in Jahia tutorial, tune in to my next video where we’ll define a view, that is an, html rendering, for this content type to display on our site."


For more on Jahia:
Website: http://jahia.com
Twitter:   / jahia  
LinkedIn:   / jahia-solutions