掲示板

Freemarker Display Date or Publish Date Variable?

thumbnail
10年前 に Ken Driscoll によって更新されました。

Freemarker Display Date or Publish Date Variable?

Junior Member 投稿: 57 参加年月日: 12/07/02 最新の投稿
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
10年前 に James Falkner によって更新されました。

RE: Freemarker Display Date or Publish Date Variable? (回答)

Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
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
10年前 に Ken Driscoll によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

Junior Member 投稿: 57 参加年月日: 12/07/02 最新の投稿
Thanks James!
thumbnail
9年前 に Emil Öberg によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

New Member 投稿: 5 参加年月日: 11/04/19 最新の投稿
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
9年前 に shima shima によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

Junior Member 投稿: 46 参加年月日: 14/04/14 最新の投稿
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
9年前 に Andew Jardine によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
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
9年前 に shima shima によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

Junior Member 投稿: 46 参加年月日: 14/04/14 最新の投稿
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
9年前 に Andew Jardine によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
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.
9年前 に shima shima によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

Junior Member 投稿: 46 参加年月日: 14/04/14 最新の投稿
is there anybody could help more?
7年前 に Mark M によって更新されました。

RE: Freemarker Display Date or Publish Date Variable?

New Member 投稿: 1 参加年月日: 17/01/06 最新の投稿
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>