Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Sort data by descending date in freemarker template
Hello Team , I am creating one web content used to show latest news . I have created structure and template for the same also able to sort it by date but problem is its showing latest date at bottom i want to show latest news at top. Kindly help me to resolve this problem .
To sort the data i am using below line <#list NewsTitle.getSiblings()?sort_by(["NewsDate","data"]) as cur_NewsTitle>
NewsDate is the date field in structure.
Here is the attachment for the work 1.png - structure screenshot2.png - final look of web content on pagestructure - structure sourcefreemarker - template to render the web content
To sort the data i am using below line <#list NewsTitle.getSiblings()?sort_by(["NewsDate","data"]) as cur_NewsTitle>
NewsDate is the date field in structure.
Here is the attachment for the work 1.png - structure screenshot2.png - final look of web content on pagestructure - structure sourcefreemarker - template to render the web content
How about: (I have added "?reverse")
<#list NewsTitle.getSiblings()?sort_by(["NewsDate","data"])?reverse as cur_NewsTitle>
<#list NewsTitle.getSiblings()?sort_by(["NewsDate","data"])?reverse as cur_NewsTitle>
Christoph Rabel:
How about: (I have added "?reverse")
<#list NewsTitle.getSiblings()?sort_by(["NewsDate","data"])?reverse as cur_NewsTitle>
Hello Christoph , your solution worked . Thank you for your help !!!!!
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™