Search in the Documentation:

Introduction to templates

We’ve seen quickly in the first part of this document that templates are guidelines for editors when creating pages, and used by Jahia to generate final HTML pages by gathering nodes and placing them it the right place.

As a developer, it is important for you to understand what exactly a template is and how the mechanism works. We’ll use an analogy to explain that.

Imagine that a template is a wooden tray like the ones small kids play with. The wooden tray has holes of various shapes, and the kid has corresponding wooden pieces. The aim of the game is to fill the holes with the wood pieces.

[image]

Templates are similar to those trays. As a template developer you start with a simple plain plank, and you dig holes in that tray. Each hole has a well-defined position and a name. Holes are called areas in the Jahia lingo.

On the other side, the wood pieces are the content objects the editors (the child) can insert in those holes. Each content object has a different shape so we can compare shapes to content definitions. Jahia provides by default a large number of pieces of different shapes, but you, as a developer, can reshape some of them (customize Jahia), remove some of them, or add news ones the kids will be allowed to play with.

Where Jahia differs from a standard wooden tray (and from most CMS) is that the areas can be filled nicely by any piece of wood, while a cubic hole will normally never receive a star or a circle. That’s magic! By default an area is just a position and therefore it’s very easy for kids to insert their wooden cubes or triangles.

It happens that kids must be driven a bit, that’s why you can also define that an area can receive only cubes, or only cubes and stars, or cubes, stars and rectangles, even specify a number of items that a particular hole can accept. Defining those restrictions is typical templating work that responds to ergonomic or functional constraints.

Finally, thanks to views, the same wooden tray with the same wood pieces can produce very different results at the end. Defining the default view that will be applied when content is added in particular positions of the pages is also part of the template development work. It’s up to you to decide if the kids can turn their cubes (change the view) or not.

[image][image]