Forums de discussion

Freemarker Display Date or Publish Date Variable?

thumbnail
Ken Driscoll, modifié il y a 10 années.

Freemarker Display Date or Publish Date Variable?

Junior Member Publications: 57 Date d'inscription: 02/07/12 Publications récentes
Hi, I am creating a Freemarker Template in Liferay 6.2 for a web-content structure. I know in the past there were specific variables in Velocity for getting the display date ($reserved-article-display-date.data). Is there a similar variable in a Freemarker template for getting either the display date or the publish date?

Many thanks in advance!
thumbnail
James Falkner, modifié il y a 10 années.

RE: Freemarker Display Date or Publish Date Variable? (Réponse)

Liferay Legend Publications: 1399 Date d'inscription: 17/09/10 Publications récentes
Ken Driscoll:
Hi, I am creating a Freemarker Template in Liferay 6.2 for a web-content structure. I know in the past there were specific variables in Velocity for getting the display date ($reserved-article-display-date.data). Is there a similar variable in a Freemarker template for getting either the display date or the publish date?

Many thanks in advance!


The same variables and their values are available in Freemarker too - but you have to use a slightly odd syntax due to the Freemarker syntax rules (where a dash means mathematical subtraction). So you can do
${.vars['reserved-article-display-date'].data}
thumbnail
Ken Driscoll, modifié il y a 10 années.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Publications: 57 Date d'inscription: 02/07/12 Publications récentes
Thanks James!
thumbnail
Emil Öberg, modifié il y a 9 années.

RE: Freemarker Display Date or Publish Date Variable?

New Member Publications: 5 Date d'inscription: 19/04/11 Publications récentes
For people like me Googling their way here:

When working with multilingual/non-English sites, date/time-stamp can be a bit of a headache as the date strings are strings with english words in them, such as Thu, 08 May 2014 11:48:00 +0000, rather than a unix timecode.

Here's an example of how to take a date/time-string (such as publish date), make it into a date/time-object and being able to print the date/time in the language/format you want. Just remove some excessive code if you're working with an English-only site.

https://gist.github.com/emiloberg/b4382b9a6946a183cddd
shima shima, modifié il y a 9 années.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Publications: 46 Date d'inscription: 14/04/14 Publications récentes
it was very useful . would u plz explain more about reserved fields such as category, title, tages,.. . how can fetch them and show .
${ reserved -articlie- tilte.getData()} dose not workemoticon
thumbnail
Andew Jardine, modifié il y a 9 années.

RE: Freemarker Display Date or Publish Date Variable?

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
I think you asked this one in another thread. don't wrap the variable name in curly braces {} ... velocity vars start with a $ and then go right into the name. So

${reserved-variable-name}.data

instead used --

$reserved-variable-name.data
shima shima, modifié il y a 9 années.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Publications: 46 Date d'inscription: 14/04/14 Publications récentes
yes Andew I found my answer : ${.vars['reserved-article-title'].data}
this format works for all reserved value but what about tag and category"???emoticon
thumbnail
Andew Jardine, modifié il y a 9 années.

RE: Freemarker Display Date or Publish Date Variable?

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
I don't think either of those (I know for sure that tags aren't) are part of the reserved list. You will need to load the service utils in the velocity template and then leverage the various api calls to get those details for the article.
shima shima, modifié il y a 9 années.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Publications: 46 Date d'inscription: 14/04/14 Publications récentes
is there anybody could help more?
Mark M, modifié il y a 7 années.

RE: Freemarker Display Date or Publish Date Variable?

New Member Envoyer: 1 Date d'inscription: 06/01/17 Publications récentes
For Liferay 7.0 (using a Freemarker Template)

<!-- Load the List

<#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)>

<!-- Order the List

<#assign records = ddlDisplayTemplateHelper.getRecords(87355, -1, -1, -1, orderby)>

<!-- Replace 87355 with the 'Data Definition ID' of your list

<!-- render the records on the page

<#if records?has_content>
<#list records as cur_record>

<!-- all your styling and formatting here

</#list>
</#if>