Wednesday, April 27, 2016

Generic Templates Liferay 6.2


Before Liferay 6.2, each template had to be associated with a structure. Now, we can create a generic template and reuse its code for any structure. Generic templates can be embedded in other templates, which allows for reusable code,

Suppose you have three different web content articles and structures with similar requirements. Instead of creating three different templates from scratch, you can use the same generic template for all three and build off of it. This creates a smarter and more efficient process when creating a multitude of similar web content articles. Generic templates are created the same way as regular, structure-based templates. The only setting that differs is the Structure option, which you’ll need to leave blank to create a generic template.

Embedding Generic Template in other template:

In FreeMarker:
<#include "${templatesPath}/<generic-template-key>" />


In Velocity:

#parse ("$templatesPath/<generic-template-key>")