Foren

Freemarker Display Date or Publish Date Variable?

thumbnail
Ken Driscoll, geändert vor 10 Jahren.

Freemarker Display Date or Publish Date Variable?

Junior Member Beiträge: 57 Beitrittsdatum: 02.07.12 Neueste Beiträge
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, geändert vor 10 Jahren.

RE: Freemarker Display Date or Publish Date Variable? (Antwort)

Liferay Legend Beiträge: 1399 Beitrittsdatum: 17.09.10 Neueste Beiträge
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, geändert vor 10 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Beiträge: 57 Beitrittsdatum: 02.07.12 Neueste Beiträge
Thanks James!
thumbnail
Emil Öberg, geändert vor 9 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

New Member Beiträge: 5 Beitrittsdatum: 19.04.11 Neueste Beiträge
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, geändert vor 9 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Beiträge: 46 Beitrittsdatum: 14.04.14 Neueste Beiträge
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, geändert vor 9 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
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, geändert vor 9 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Beiträge: 46 Beitrittsdatum: 14.04.14 Neueste Beiträge
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, geändert vor 9 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
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, geändert vor 9 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

Junior Member Beiträge: 46 Beitrittsdatum: 14.04.14 Neueste Beiträge
is there anybody could help more?
Mark M, geändert vor 7 Jahren.

RE: Freemarker Display Date or Publish Date Variable?

New Member Beitrag: 1 Beitrittsdatum: 06.01.17 Neueste Beiträge
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>