Forums de discussion

How to access Calendar Event fields in Application Display Template (ADT)

Vyash Janki, modifié il y a 9 années.

How to access Calendar Event fields in Application Display Template (ADT)

New Member Envoyer: 1 Date d'inscription: 14/10/14 Publications récentes
Hi!

I've created a custom ADT for my Asset Publisher whereby I want to display Calender events only. Now, I want to display, let's say the start and end date of an event. I'm currently struggling with:


#if (!$entries.isEmpty())
	#foreach ($entry in $entries)
		$entry.getStartDate()
		<br>
		$entry.getEndDate()
	#end
#end


Needless to say it isn't working. So how do I access Calendar events-related fields (start date, location, ...) in an ADT?!
thumbnail
James Falkner, modifié il y a 9 années.

RE: How to access Calendar Event fields in Application Display Template (AD

Liferay Legend Publications: 1399 Date d'inscription: 17/09/10 Publications récentes
How about:
#set ($calService = $utilLocator.findUtil("calendar-portlet", "com.liferay.calendar.service.CalendarBookingLocalService"))

#if (!$entries.isEmpty())
	#foreach ($entry in $entries)
	    #set ($calBookingEntry = $calService.getCalendarBooking($entry.getAssetRenderer().getClassPK()))
	    <ul>
	      <li>Title: $calBookingEntry.getTitle($locale)</li></ul>
	      <li>Start: $dateTool.format($calBookingEntry.getStartTime())
          </li>
  • End: $dateTool.format($calBookingEntry.getEndTime()) #end #end
  • Rahul Joshi, modifié il y a 6 années.

    RE: How to access Calendar Event fields in Application Display Template (AD

    Junior Member Publications: 63 Date d'inscription: 03/03/17 Publications récentes
    Any help on how I can sort the calendar events by the event date?
    Sourabh Lonikar, modifié il y a 6 années.

    RE: How to access Calendar Event fields in Application Display Template (AD

    Junior Member Publications: 42 Date d'inscription: 14/11/16 Publications récentes
    James Falkner:
    How about:
    #set ($calService = $utilLocator.findUtil("calendar-portlet", "com.liferay.calendar.service.CalendarBookingLocalService"))
    
    #if (!$entries.isEmpty())
    	#foreach ($entry in $entries)
    	    #set ($calBookingEntry = $calService.getCalendarBooking($entry.getAssetRenderer().getClassPK()))
    	    <ul>
    	      <li>Title: $calBookingEntry.getTitle($locale)</li></ul>
    	      <li>Start: $dateTool.format($calBookingEntry.getStartTime())
              </li>
  • End: $dateTool.format($calBookingEntry.getEndTime()) #end #end


  • Hi James.
    This start date is coming in msec format as string. Hence I cannot use "?string["yyyy-MM-dd"]}" for showing date in proper format. How should I go about to get date in proper format ?

    Regards,
    Sourabh Lonikar, modifié il y a 6 années.

    RE: How to access Calendar Event fields in Application Display Template (AD

    Junior Member Publications: 42 Date d'inscription: 14/11/16 Publications récentes
    I am using below code to get date in proper format but I am getting wrong date:

    calBookingEntry.getStartTime()?datetime("ssssssssssssssss")?string["yyyy-MM-dd"]

    Actual Output : 2014-09-15
    Desired Output : 2017-07-18