Freemarker + current date

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2006 08:37 AM
Hi there,
I'm building a Freemarker template with the whole folder structure to have an administrative overview of our Alfresco system. I need the current date in the following expression:
Freemarker is a templating language so there is no such thing as "today". Is there some exposed variable in Alfresco I could use?
I'm building a Freemarker template with the whole folder structure to have an administrative overview of our Alfresco system. I need the current date in the following expression:
<#assign modifiedToday=""><#if "2006.05.08" == childnode.properties.modified?string("yyyy.MM.dd")>…do something…</#if>
Freemarker is a templating language so there is no such thing as "today". Is there some exposed variable in Alfresco I could use?
Labels:
- Labels:
-
Archive
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2006 10:46 AM
I also noticed this strange lack of a Date object in FreeMarker and added it to the Alfresco templating data-model. So the current date (as a new Date() Java object) can be accessed in a template as the "date" object in the root of the model. For example:
Hope this helps,
Kevin
<#assign datetimeformat="EEE, dd MMM yyyy HH:mm:ss zzz">${date?string(datetimeformat)}
Hope this helps,
Kevin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2006 11:33 AM
Perfect, this is exactly what I needed! Thanks Kevin.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 02:47 PM
does this date get created on each call within a template or just once?
It looks like it's just once as all my times are the same.
I am trying to debug a long running custom view template and see which queries are taking how long. I was printing the time including milliseconds before and after each, but there are all identical
How can I get accomplish this?
thx
It looks like it's just once as all my times are the same.
I am trying to debug a long running custom view template and see which queries are taking how long. I was printing the time including milliseconds before and after each, but there are all identical
How can I get accomplish this?
thx
I also noticed this strange lack of a Date object in FreeMarker and added it to the Alfresco templating data-model. So the current date (as a new Date() Java object) can be accessed in a template as the "date" object in the root of the model. For example:<#assign datetimeformat="EEE, dd MMM yyyy HH:mm:ss zzz">${date?string(datetimeformat)}
Hope this helps,
Kevin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2007 05:31 AM
A new Date() object is created at the start of each template execution, it is not dynamically generated each time you use it on the page.
To add a dynamic Date object, you can configure in a custom class that does what you want:
http://wiki.alfresco.com/wiki/Template_Guide#Custom_Root_Objects
Thanks,
Kevin
To add a dynamic Date object, you can configure in a custom class that does what you want:
http://wiki.alfresco.com/wiki/Template_Guide#Custom_Root_Objects
Thanks,
Kevin
