How can I sort by "date2"? That is, on the additional field "date"?
<#assign
orstf = objectUtil('com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil')
qry = assetEntryLocalService.dynamicQuery()
/>
<#if startDate??>
<#assign
V = qry.add(orstf.ge('publishDate', startDate?date("dd.MM.yyyy") ))
/>
</#if>
<#if endDate??>
<#assign
V = qry.add(orstf.le('publishDate', endDate?date("dd.MM.yyyy")))
/>
</#if>
<#assign
entriesRaw = assetEntryLocalService.dynamicQuery(qry)
entries = []
/>
<#-- ?sort_by(['name', 'last']) -->
<#list entriesRaw as entry>
<#assign
eCatIds = entry.getCategoryIds()
renderer = entry.getAssetRenderer()
journalArticle = renderer.getArticle()
date2 = journalArticle.getExpandoBridge().getAttribute("date")
bContains = 0
/>
<#list eCatIds as eCatId>
<#if (catIds?seq_contains(eCatId)) &&
(date2?date >= startDate?date("dd.MM.yyyy")) &&
(date2?date <= endDate?date("dd.MM.yyyy")) >
<#assign bContains = 1 />
</#if>
</#list>
<#if bContains == 1>
<#--
<#assign entry.set />
-->
<#assign entries = entries + [entry] />
</#if>
</#list>
I thought it might work out, write it down to some field of the asset. And on this sort. But this is also not good, every time the database is tugged
Especially in the Netsuite fork of FreeMarker, you won't do this (assuming you can't add helpers written in Java), because that fork doesn't even support
?map, which can be used for sorting by a calculated filed, likedate2is here. (Although even with that,?sort_byas of 2.3.31 only supports sorting by a single field, so you had to do some hack where you concatenate the two fields into one. Even if?sort_bywill be improved in FreeMarker later, that certainly won't make its way into the Netsuite fork, sadly.)Anyway, the assumption in FreeMarker is that sorting and other such query operations (like joins, etc.) is the duty of the data access layer, not of the template. In this vein, it's certainly
assetEntryLocalService.dynamicQuerythat should support whatever sorting the reports need.