The application display template (ADT) allows portal administrators to override the default display templates for portlets. For example, we want to show a list of the asset ( web contents, blogs ) in the asset publisher portlet in different designs ( Vertical list ) than OOTB design of LIferay. Application display template(ADT) is a great way of changing the Portlet display dynamically without changing code in Portlet JSP pages. In Liferay 7.2, application display template known as Widget Template.
Follow the below steps to create Web Content with structure and template
1) Create Structure
- Go to Liferay admin panel
- Go to Sites → Select desired site → Content → Web-content → Structures
- Click on “+” button
- Enter the name of the structure
- Add fields by dragging items from left to right
- And click on the “Save” button to save the structure
2) Create Template
- Go to Liferay admin panel
- Got to Sites → Select desired site → Content → Web-content → Templates
- Click on “+” button
- Enter the name of the template
Title : ${Title.getData()}
Description : ${Description.getData()}
<#if Image.getData()?? && Image.getData() != "">
#if>
3) Create Web Content
- Go to Liferay admin panel
- Got to Sites → Select desired site → Content → Web-content
- Click on “+” button
- Select the structure
- Give the name of web content
- Fill the fields with appropriate details
- Click on Publish
- Go to the desired page
- Drop the Web Content Display portlet
- Click on Select Web Content to make it visible
- Select the web content which you want to display
We can add any number of web contents using this structure and template. We can configure asset publisher to render web content using this structure. Now in order to make look and feel better we can write application display template to render webcontents list.
Follow the below steps to create the Application Display Template
Create Application Display Template using asset publisher
- Go to Liferay admin panel
- Got to Sites → Select desired site → Configuration → Application Display Templates
- Click on “ADD” button
- Select Asset Publisher Template
- Add the name of the asset publisher
- Add below code in ADT
<#if entries?has_content>
<#list entries as curEntry>
<#assign
assetRenderer = curEntry.getAssetRenderer()
journalArticle = assetRenderer.getAssetObject()
/>
<@liferay_journal["journal-article"]
articleId=journalArticle.getArticleId()
ddmTemplateKey=journalArticle.getDDMTemplateKey()
groupId=journalArticle.getGroupId()
/>
#list>
#if>
- Click on the Save button
- Go to the desired page
- Drop the Asset Publisher portlet, configure it with above ADT and structure