Tuesday 7 January 2014

Application Display Templates - One of the New Features in Liferay 6.2


                       Liferay comes with many collaboration functionality related portlets like Asset Publisher, Blogs, Wiki, Media Gallery.

                      Many  times client has requirement which differs in terms of look and feel from this OOB portlets, to achieve such requirement the only way before Liferay 6.2 was to create jsp hook and do modification to jsp files. But this doesnt required any more if your requirement is not so complex.

                      Liferay 6.2, comes with concept "Application Display Templates",  WithApplication Display Templates, you can define custom display templates used to render asset-centric applications.

Liferay comes with 7 Application Display Templates as shown in image below.

 Each of Edit Screen for Application Display Template contains respective variables to use in Editor.

For Example: Asset Entries/ Blog Entries / Pages / Tags / Documents are available as entries variable in respective templates

           
Lets understand it by example:
Say you want to display list of Asset Entries in Asset Publisher with just title and date[with format dd MM yyyy].

To achieve this create on Asset Publisher Template, with script as below.
 #if (!$entries.isEmpty())  
   #foreach ($curEntry in $entries)  
     <a href='$assetPublisherHelper.getAssetViewURL($renderRequest, $renderResponse, $curEntry)'>$curEntry.getTitle($locale)</a>  
     $dateTool.format("dd MMM yyyy",  
  $dateTool.toDate("EEE, dd MMM yyyy hh:mm:ss Z", $curEntry.getPublishDate()), $locale)  
     <br/>  
     #end  


       
And then in Asset Publisher's Configuration Display Setting >  Display Template, select your created Asset Publisher Template and save configurations.
Similarly, you can set Display Template for portlets like Blogs, Wiki, Tags navigation, Categories navigation, SiteMap, Media Gallery etc.

By this you will see list of assets with Published date in particular format.

Thus, you can customize view of Asset Publisher portlet.

Similarly, you can also customize view for Blogs portlet, Tags navigation, Site Map, Categories Navigation, Media Gallery.

You will find default Carousel Display Template for Media Gallery in Liferay 6.2 version.

Cheers!

7 comments:

  1. Nice work,
    I want to display a custom field "link to page" from my web content structure in my asset publisher using "Asset Publisher Template",
    didyou have any idea on how to do that ?
    Thanks

    ReplyDelete
  2. How would I set the date format to be like: 21h45 with an "h"? I'm getting something like: 09945, because I put hhhmm.

    ReplyDelete
  3. @Thiago : try with this format : HH'h'mm

    ReplyDelete
  4. Hi...How can I get the liferay Select categories (countrynames) in select field in ADT ...liferay 6.2

    ReplyDelete
  5. J’aime beaucoup cet article et ces informations me sont utiles. Le projet Liferay Module est incroyable. Nous proposons également différents Liferay Développement France. Contactez-nous pour obtenir plus de détails.

    ReplyDelete