Search in the Documentation:

In practice: create the node type definition for dogs

Let’s now create the dog node type we wish to manipulate in our site and start by resuming how a dog can be defined with spoken words

Let’s say a dog has a name (but all nodes in the JCR have a name, so we don’t need to create a property for that) as well as a nickname. A dog can have a short or a long coat, it can already be a champion or not, it can be for sale or not. If it is for sale, then we need to give it a price. The dog has a gender; it is born on a particular date from a father and a mother who might be also in our database so we want to be able to create links to those dogs. We need to present the dog with a main photo, and we want to provide a description in several languages. The dog has a color from a selection of colors authorized by the international standard, colors which are spelled differently depending on the languages. The size of its ears is important, as well as the size and the shape of its tail. As our dogs are only Chihuahuas the weight must be between 1.0 kg and 2.99 kg. Finally we want to be able to attach any number of photos to a dog.

Let’s start by declaring the dog content type and make it a child of the generic jnt:content type

[cnt:dog] >jnt:content

Following the above description, let’s add the properties with their types and default values

[cnt:dog] >jnt:content
- nickname (string)
- coat (string) < 'long','short'
- champion (boolean)
- forSale (boolean)
- price (long)
- gender (string, choicelist[resourceBundle]) < 'female','male'
- birthdate (date)
- father (weakreference, picker[type='dog'])
- mother (weakreference, picker[type='dog'])
- mainPicture (weakreference, picker[type='image'])
- biography (string, richtext) i18n
- color (string, choicelist[resourceBundle]) < 'black','red', 'fawn', 'cream', 'blue', 'chocolate', 'sable', 'silver', 'brindle'
- ears (string, choicelist[resourceBundle]) < 'large','medium', 'small'
- tail_size (string, choicelist[resourceBundle]) < 'long','short', 'medium'
- tail_shape (string, choicelist[resourceBundle]) < 'curved','straight'
- weight (long) < ‘^[1-2]\.?\d*$‘
+ * (jnt:imageReference) 

We can now improve this definition by specifying some indexing information

[cnt:dog] >jnt:content
- nickname (string)
- coat (string) < 'long','short'
- champion (boolean)
- forSale (boolean)
- price (long)
- gender (string, choicelist[resourceBundle]) analyzer='keyword' < 'female','male'
- birthdate (date) nofulltext
- father (weakreference, picker[type='dog'])
- mother (weakreference, picker[type='dog'])
- mainPicture (weakreference, picker[type='image'])
- biography (string, richtext) i18n
- color (string, choicelist[resourceBundle]) analyzer='keyword' < 'black','red', 'fawn', 'cream', 'blue', 'chocolate', 'sable', 'silver', 'brindle'
- ears (string, choicelist[resourceBundle]) < 'large','medium', 'small'
- tail_size (string, choicelist[resourceBundle]) < 'long','short', 'medium'
- tail_shape (string, choicelist[resourceBundle]) < 'curved','straight'
- weight (long) indexed=no < ‘^[1-2]\.?\d*$‘
+ * (jnt:imageReference) 

Then, we want this content type to be drag&droppable by editors in the Edit Mode GUI.
We want this content type to be recognized by Jahia as an “Editorial Content”, a classification for content with readable data, by opposition to feature oriented content such as lists, rating, polls, etc.
Finally we want the component to appear in the Selector in the “Content:structured” category.

[cnt:dog] >jnt:content, jmix:editorialContent, jmix:droppableContent, jmix:structuredContent
- nickname (string)
- coat (string) < 'long','short'
- champion (boolean)
- forSale (boolean)
- price (long)
- gender (string, choicelist[resourceBundle]) analyzer='keyword' < 'female','male'
- birthdate (date) nofulltext
- father (weakreference, picker[type='dog'])
- mother (weakreference, picker[type='dog'])
- mainPicture (weakreference, picker[type='image'])
- biography (string, richtext) i18n
- color (string, choicelist[resourceBundle]) analyzer='keyword' < 'black','red', 'fawn', 'cream', 'blue', 'chocolate', 'sable', 'silver', 'brindle'
- ears (string, choicelist[resourceBundle]) < 'large','medium', 'small'
- tail_size (string, choicelist[resourceBundle]) < 'long','short', 'medium'
- tail_shape (string, choicelist[resourceBundle]) < 'curved','straight'
- weight (long) indexed=no < ‘^[1-2]\.?\d*$‘
+ * (jnt:imageReference)