Fórum

Sort Calendar Events in Asset Publisher

Rahul Joshi, modificado 6 Anos atrás.

Sort Calendar Events in Asset Publisher

Junior Member Postagens: 63 Data de Entrada: 03/03/17 Postagens Recentes
I am showing Calendar Events in an Asset Publisher. I need to sort them by the date of event and not by options like- created/modified etc. How can I do this?
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Which version of Liferay are you using?
Rahul Joshi, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Junior Member Postagens: 63 Data de Entrada: 03/03/17 Postagens Recentes
It is Liferay 7.
Rahul Joshi, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Junior Member Postagens: 63 Data de Entrada: 03/03/17 Postagens Recentes
Any help on this Andrew?
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Rahul,

Sorry -- I haven't had a chance to dig into it, but I'll see if I can carve out some time to have a look today and get back to you (if no one else gets back to you first). One question -- is this asset publisher ONLY showing calendar event records? Or will the event records be mixed in with other record types?
Rahul Joshi, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Junior Member Postagens: 63 Data de Entrada: 03/03/17 Postagens Recentes
Andrew Jardine:
Hi Rahul,

Sorry -- I haven't had a chance to dig into it, but I'll see if I can carve out some time to have a look today and get back to you (if no one else gets back to you first). One question -- is this asset publisher ONLY showing calendar event records? Or will the event records be mixed in with other record types?


Thanks for the response Andrew. It is only the calendar event.
David Weitzel, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Junior Member Postagens: 65 Data de Entrada: 07/10/15 Postagens Recentes
I did this in liferay 6.23 and am about to convert it to 7

basic approach was to create an array with the event id, epoch and viewurl and then sort on epoch before listing

I used different settings in the standard asset publisher configuration to decide if it was just future events or all events to be listed.

This has som eside effects like "throwing away" past evens from the x sleected by asste publisher so sometimes you had short lists when you may expect more, but of you know your data that is manageable.

	<#assign array= [] />
	<#list entries as curEntry>
		<#assign calendarBooking = calendarBookingService.getCalendarBooking(curEntry.getClassPK()) />
		<#assign startTime = calendarBooking.getStartTime() />
		
		<#assign assetRenderer = curEntry.getAssetRenderer() />
        
        <#assign entryTitle = htmlUtil.escape(assetRenderer.getTitle(locale)) />

    	<#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, curEntry) />
		<#assign viewURL = assetRenderer.getURLViewInContext(renderRequest, renderResponse, viewURL) />
	
		<#assign array =  array + [{"classPK":curEntry.getClassPK() , "epoch":startTime, "viewURL":viewURL } ] /> 
	<!--#list-->
	&lt;#list array?sort_by("epoch") as i&gt;
		&lt;#assign calendarBooking = calendarBookingService.getCalendarBooking(i.classPK) /&gt;
		&lt;#assign viewLink = i.viewURL /&gt;
		&lt;#assign eventId= i.classPK /&gt;
		&lt;#assign viewLinkwBack= httpUtil.setParameter(viewLink,"backURL", backURL) /&gt;		
		&lt;#assign startDate = i.epoch?number_to_datetime /&gt;
		&lt;#assign endDate = calendarBooking.getEndTime()?number_to_datetime /&gt;
		&lt;#assign allDay = calendarBooking.getAllDay() /&gt;
	    &lt;#assign times = calendarBooking.getStartTime() /&gt;
	    &lt;#assign desc = calendarBooking.getDescription(locale) /&gt;
	    &lt;#assign location = htmlUtil.escape(calendarBooking.getLocation())  /&gt;
	    &lt;#assign sTime = startDate?time /&gt;
...
...
...

	
Rahul Joshi, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Junior Member Postagens: 63 Data de Entrada: 03/03/17 Postagens Recentes
Thanks David. Let me have a look at this as well.
Rahul Joshi, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Junior Member Postagens: 63 Data de Entrada: 03/03/17 Postagens Recentes
I tried with this and it is returning error:

The following has evaluated to null or missing:
==&gt; calendarBookingService  [in template "20155#20195#334983" at line 3, column 33]

----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use &lt;#if myOptionalVar??&gt;when-present&lt;#else&gt;when-missing<!--#if-->. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
 - Failed at: #assign calendarBooking = calendarBoo...  [in template "20155#20195#334983" at line 3, column 6]
----
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Since some of this conversation has moved into the new slack channel, I just wanted to update the thread with something that someone added to the conversation, pointing to a marketplace plugin that solves this issue: https://web.liferay.com/marketplace/-/mp/application/89449030
Rahul Joshi, modificado 6 Anos atrás.

RE: Sort Calendar Events in Asset Publisher

Junior Member Postagens: 63 Data de Entrada: 03/03/17 Postagens Recentes
Thanks for sharing this link Andrew. I will check if this would suffice the requirement