我已在 Liferay 中为日历创建了application display template(ADT),我想按 startDate 排序列表。从Asset Publisher配置中,我只能按"创建日期","修改日期","发布日期"和"到期日期"。
按"开始日期"或"结束日期"我必须以编程方式完成。
我使用 FreeMarker 作为语言,我尝试如下:
<#assign calService = utilLocator.findUtil("calendar-portlet", "com.liferay.calendar.service.CalendarBookingLocalService") />
<#list entries?sort_by("startDate") as curEntry>
<#assign calBookingEntry = calService.getCalendarBooking(curEntry.getAssetRenderer().getClassPK()) />
<#assign startTime = getterUtil.getLong(calBookingEntry.getStartTime()) />
<#assign endTime = getterUtil.getLong(calBookingEntry.getEndTime()) />
<div>
<h2>${calBookingEntry.getTitle(locale)}</h2>
<p>${calBookingEntry.getDescription(locale)}</p>
</div>
</#list>
但是我收到了这个错误。
?sort_by(...) failed at sequence index 0: The "startDate" subvariable was not found.
然后我检查了哈希中的键值对:
{
entryId=21374,
groupId=20182,
companyId=20155,
userId=20199,
userName=Test Test,
createDate=Tue Jun 21 15:12:06 GMT 2016,
modifiedDate=Fri Aug 12 12:59:41 GMT 2016,
classNameId=20440,
classPK=21370,
classUuid=c4b0008d-ba07-4f63-a858-3f5f4f0fff08,
classTypeId=0,
visible=true,
startDate=null,
endDate=null,
publishDate=null,
expirationDate=null,
mimeType=text/html,
title=title tes,
description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris id tortor at odio elementum auctor non ut orci.,
summary=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris id tortor at odio elementum auctor non ut orci. ,
url=,
layoutUuid=,
height=0,
width=0,
priority=0.0,
viewCount=0
}
我注意到startDate
键没有值( null ),但在数据库表 [table:CalendarBooking
中,列:{{1 }}] 具有此值:startTime