Liferay Application Display Template (ADT) is a new feature which is added in Liferay 6.2. Using Application Display Template we can define custom display templates for a given portlet. For example we want to show blog entries horizontally instead of vertically or list our assets in the asset publisher portlet in different sizes. The Application Display Template feature is fully dynamic. This means that, once Application Data Template is applied to a particular portlet the display formate of the data will be changed on the fly. No need to restart your server.
Existing Application Display Template:
Application Display Templates are associated with sites. So before finding or modifying the template we have to fist find out the site. Liferay provides some default Application Display Templates for the portlets Wiki, Blogs, Asset Publisher, Document and Media etc.To see all these templates navigate as below
Control Panel → Sites→Click Any Site→Application Display Template
Note: An Application Display Template in Global Scope are accessible to any sites. That mean if we want to use an Application Display Template in various sites then we should create the template in Global SCOPE. Any template other than global scope can be used only in that site.
Using Application Display Template:
We have seen that there are some templates available in the control panel. But how to use those templates? Media Gallery Portlet can be used to demonstrate how to use the existing templates. Add the Media Gallery portlet in any page. Below is the portlet look and feel by default.
We are going to modify the look and feel using Carousel template. To use the template go to the configuration page of the portlet. Select carousel as below and then save it.
What we have done here:
We have just applied a template called carousel to the media gallery portlet. So after applying the template the media gallery portlet should display carousel images. Below is the look and feel after applying the template.
Q: Is it possible to apply ADT to any portlets?
A: No. By default ADT can be applied to only Asset Publisher, Blogs, Categories Navigation, Media Gallery, Site Map, Tags Navigation and Wiki Portlet.
Q: Is it possible to use ADT in custom portlet?
A:Yes. At the time of development we should take care of it to support ADT.
Q:Can we have multiple templates for a portlet?
A:Yes.
Q:Liferay provides some templates for out of box portlets. Can we create our own templates for those portlets?
A:Yes. We can create any number of templates for those portlets. In liferay control panel we can create the templates.
Q: For creating templates do we need any tools?
A:No. Liferay portal is sufficient. From the control panel using drag and drop features we can create templates.
Q: Do we need to learn new programming language to create templates?
A: No.You should have a basic knowledge either in Velocity or in free marker scripting language.