I am writing an Application Display Template for an Asset Publisher in Liferay (6.2 GA5) in Freemarker and I want to display the author and the creation date. A while ago I needed the same variables for a template and I found matching Velocity variables:
$reserved-article-author-name
& $reserved-article-create-date.data
To use Velocity variables in FreeMarker, I called them like this: ${.vars['reserved-article-author-name'].data}
In my Template, it works fine, in my ADT, it throws an error:
Expression .vars['reserved-article-author-name'] is undefined
How do you manage to get these variables to work in my ADT or is there an alternative way to get this information?
Those "reserved article" variables are only set when processing Web Content Templates.
With ADTs you have much more fine-grained access to the displayed assets but have to use a different way of accessing, since those reserved variables aren't available. Assets have a generic set of metadata (name, date, title, etc) that you can access. For your example, the code would be:
<#if entries?has_content>
<#list entries as curEntry>
Title: ${curEntry.getTitle(locale)}
Create Date: ${curEntry.createDate?date}
Author: ${curEntry.userName}
</#list>
</#if>
Check out this Rich Summary for Asset Publisher to see how to access metadata for specific asset types (blogs, wikis, etc).