Foren

Message Board threads sorting

Shahin Ali, geändert vor 12 Jahren.

Message Board threads sorting

New Member Beiträge: 24 Beitrittsdatum: 03.05.11 Neueste Beiträge
Can i change the sorting order of message thread posts in the message boards to 'last posted first'

present order is first posted first

using liferay 6 EE

Thanks.
thumbnail
Corné Aussems, geändert vor 12 Jahren.

RE: Message Board threads sorting

Liferay Legend Beiträge: 1313 Beitrittsdatum: 03.10.06 Neueste Beiträge
Shahin Ali:
Can i change the sorting order of message thread posts in the message boards to 'last posted first'

present order is first posted first

using liferay 6 EE

Thanks.



Try a hook on the MBMessageLocalServiceImpl
and implement your own MessageThreadComparator
	public List<mbmessage> getThreadMessages(long threadId, int status)
		throws SystemException {

		return getThreadMessages(
			threadId, status, new MessageThreadComparator());
	}

</mbmessage>


Some old but very clear introduction
http://www.liferay.com/web/amos.fong/blog/-/blogs/minimizing-the-ext-environment
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: Message Board threads sorting

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
I forgot how I did it for my system, but something like changing DESC to ASC in \custom-sql\messageboards.xml

MBCategory.lastPostDate DESC
thumbnail
Corné Aussems, geändert vor 12 Jahren.

RE: Message Board threads sorting

Liferay Legend Beiträge: 1313 Beitrittsdatum: 03.10.06 Neueste Beiträge
Maybe i mis understood do you want:
Threads from a category in a Ascending order
or
Posts in a Thread in ascending order

@Hitoshi correct me if i'm wrong but your suggestion is only for the #first option ?!

	<sql id="com.liferay.portlet.messageboards.service.persistence.MBCategoryFinder.findByS_G_U_P">
		
			SELECT
				DISTINCT {MBCategory.*}
			FROM
				MBCategory
			INNER JOIN
				Subscription ON
					(Subscription.companyId = MBCategory.companyId) AND
					(Subscription.classNameId = ?) AND
					(Subscription.classPK = MBCategory.categoryId)
			WHERE
				(MBCategory.groupId = ?) AND
				(MBCategory.parentCategoryId = ?) AND
				(Subscription.userId = ?)
			ORDER BY
				MBCategory.lastPostDate DESC
		
	</sql>

thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: Message Board threads sorting

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
It may have been the following. I remember changing the ORDER BY for our site. There are several ORDER BY in the file and I don't remember which ones I changed. Please check them yourselves.

SELECT
DISTINCT {MBThread.*}
FROM
MBThread
INNER JOIN
MBMessage ON
(MBMessage.messageId = MBThread.rootMessageId)
WHERE
(MBThread.groupId = ?) AND
(MBThread.categoryId = ?)
ORDER BY
MBThread.priority DESC,
MBThread.lastPostDate DESC
thumbnail
Corné Aussems, geändert vor 12 Jahren.

RE: Message Board threads sorting

Liferay Legend Beiträge: 1313 Beitrittsdatum: 03.10.06 Neueste Beiträge
How could i miss that emoticon
Maybe i should not answer posts late at night.
Shahin Ali, geändert vor 12 Jahren.

RE: Message Board threads sorting

New Member Beiträge: 24 Beitrittsdatum: 03.05.11 Neueste Beiträge
This is how i am trying

1. created an extension

2. created a folder 'custom-sql' under the folder 'ext-impl\src\'

3. created below 2 files in the custom-sql folder

default-ext.xml

<!--?xml version="1.0" encoding="UTF-8"?-->
<custom-sql>
    <sql file="custom-sql/messageboards.xml" />
</custom-sql>



messageboards.xml

<!--?xml version="1.0"?-->

<custom-sql>
<sql id="com.liferay.portlet.messageboards.service.persistence.MBThreadFinder.findByG_C">
		
			SELECT
				DISTINCT {MBThread.*}
			FROM
				MBThread
			INNER JOIN
				MBMessage ON
					(MBMessage.messageId = MBThread.rootMessageId)
			WHERE
				(MBThread.groupId = ?) AND
				(MBThread.categoryId = ?)
			ORDER BY
				MBThread.priority DESC,
				MBThread.lastPostDate DESC
		
	</sql>
</custom-sql>



4. added below line to 'portal-ext.properties'

custom.sql.configs=custom-sql/default-ext.xml


5. ant direct-deploy shows build success full

6. On starting the tomcat i get the below error and fails to load properly.

07:53:15,227 ERROR [CheckEntryMessageListener:34] Unable to process message {des
tinationName=liferay/scheduler_dispatch, responseDestinationName=null, responseI
d=null, payload=null, values={receiver_key=com.liferay.portlet.announcements.mes
saging.CheckEntryMessageListener:com.liferay.portlet.announcements.messaging.Che
ckEntryMessageListener, scheduledFireTime=Mon Jul 25 07:53:14 GMT 2011}}
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.d
ao.orm.ORMException: java.lang.NullPointerException
        at com.liferay.portlet.announcements.service.persistence.AnnouncementsEn
tryFinderImpl.findByDisplayDate(AnnouncementsEntryFinderImpl.java:215)
        at com.liferay.portlet.announcements.service.impl.AnnouncementsEntryLoca
lServiceImpl.checkEntries(AnnouncementsEntryLocalServiceImpl.java:128)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
on(AopUtils.java:309)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJo
inpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:150)
        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(T
ransactionInterceptor.java:65)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
ethodAdvice.java:58)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
ethodAdvice.java:58)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
ethodAdvice.java:58)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
ethodAdvice.java:58)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invok
e(ExposeInvocationInterceptor.java:89)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:202)
        at $Proxy118.checkEntries(Unknown Source)
        at com.liferay.portlet.announcements.service.AnnouncementsEntryLocalServ
iceUtil.checkEntries(AnnouncementsEntryLocalServiceUtil.java:249)
        at com.liferay.portlet.announcements.messaging.CheckEntryMessageListener
.doReceive(CheckEntryMessageListener.java:39)
        at com.liferay.portlet.announcements.messaging.CheckEntryMessageListener
.receive(CheckEntryMessageListener.java:31)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)



Can anyone tell me where i am going wrong?

Thanks for your kind support.
Saurabh Gupta, geändert vor 11 Jahren.

RE: Message Board threads sorting

New Member Beiträge: 23 Beitrittsdatum: 24.09.12 Neueste Beiträge
@Shahin Ali
i also have this requirement like "Can i change the sorting order of message thread posts in the message boards to 'last posted first".
have you find solution which is working , plz reply. Thanks in advance