Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Shahin Ali
Message Board threads sorting
May 23, 2011 2:03 AM
Answer

Shahin Ali

Rank: Junior Member

Posts: 25

Join Date: May 3, 2011

Recent Posts

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.
Corné Aussems
RE: Message Board threads sorting
May 23, 2011 2:05 PM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1311

Join Date: October 3, 2006

Recent Posts

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
1    public List<MBMessage> getThreadMessages(long threadId, int status)
2        throws SystemException {
3
4        return getThreadMessages(
5            threadId, status, new MessageThreadComparator());
6    }


Some old but very clear introduction
http://www.liferay.com/web/amos.fong/blog/-/blogs/minimizing-the-ext-environment
Hitoshi Ozawa
RE: Message Board threads sorting
May 23, 2011 3:58 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

I forgot how I did it for my system, but something like changing DESC to ASC in \custom-sql\messageboards.xml

MBCategory.lastPostDate DESC
Corné Aussems
RE: Message Board threads sorting
May 24, 2011 1:48 PM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1311

Join Date: October 3, 2006

Recent Posts

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 ?!
 1
 2    <sql id="com.liferay.portlet.messageboards.service.persistence.MBCategoryFinder.findByS_G_U_P">
 3        <![CDATA[
 4            SELECT
 5                DISTINCT {MBCategory.*}
 6            FROM
 7                MBCategory
 8            INNER JOIN
 9                Subscription ON
10                    (Subscription.companyId = MBCategory.companyId) AND
11                    (Subscription.classNameId = ?) AND
12                    (Subscription.classPK = MBCategory.categoryId)
13            WHERE
14                (MBCategory.groupId = ?) AND
15                (MBCategory.parentCategoryId = ?) AND
16                (Subscription.userId = ?)
17            ORDER BY
18                MBCategory.lastPostDate DESC
19        ]]>
20    </sql>
Hitoshi Ozawa
RE: Message Board threads sorting
May 24, 2011 3:25 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

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
Corné Aussems
RE: Message Board threads sorting
May 25, 2011 1:08 AM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1311

Join Date: October 3, 2006

Recent Posts

How could i miss that emoticon
Maybe i should not answer posts late at night.
Shahin Ali
RE: Message Board threads sorting
July 25, 2011 12:55 AM
Answer

Shahin Ali

Rank: Junior Member

Posts: 25

Join Date: May 3, 2011

Recent Posts

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

1<?xml version="1.0" encoding="UTF-8"?>
2<custom-sql>
3    <sql file="custom-sql/messageboards.xml" />
4</custom-sql>



messageboards.xml

 1<?xml version="1.0"?>
 2
 3<custom-sql>
 4<sql id="com.liferay.portlet.messageboards.service.persistence.MBThreadFinder.findByG_C">
 5        <![CDATA[
 6            SELECT
 7                DISTINCT {MBThread.*}
 8            FROM
 9                MBThread
10            INNER JOIN
11                MBMessage ON
12                    (MBMessage.messageId = MBThread.rootMessageId)
13            WHERE
14                (MBThread.groupId = ?) AND
15                (MBThread.categoryId = ?)
16            ORDER BY
17                MBThread.priority DESC,
18                MBThread.lastPostDate DESC
19        ]]>
20    </sql>
21</custom-sql>



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

1custom.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.

 107:53:15,227 ERROR [CheckEntryMessageListener:34] Unable to process message {des
 2tinationName=liferay/scheduler_dispatch, responseDestinationName=null, responseI
 3d=null, payload=null, values={receiver_key=com.liferay.portlet.announcements.mes
 4saging.CheckEntryMessageListener:com.liferay.portlet.announcements.messaging.Che
 5ckEntryMessageListener, scheduledFireTime=Mon Jul 25 07:53:14 GMT 2011}}
 6com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.d
 7ao.orm.ORMException: java.lang.NullPointerException
 8        at com.liferay.portlet.announcements.service.persistence.AnnouncementsEn
 9tryFinderImpl.findByDisplayDate(AnnouncementsEntryFinderImpl.java:215)
10        at com.liferay.portlet.announcements.service.impl.AnnouncementsEntryLoca
11lServiceImpl.checkEntries(AnnouncementsEntryLocalServiceImpl.java:128)
12        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
14java:39)
15        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
16sorImpl.java:25)
17        at java.lang.reflect.Method.invoke(Method.java:597)
18        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
19on(AopUtils.java:309)
20        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJo
21inpoint(ReflectiveMethodInvocation.java:183)
22        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
23ReflectiveMethodInvocation.java:150)
24        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(T
25ransactionInterceptor.java:65)
26        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
27ethodAdvice.java:58)
28        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
29ethodAdvice.java:58)
30        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
31ethodAdvice.java:58)
32        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableM
33ethodAdvice.java:58)
34        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
35ReflectiveMethodInvocation.java:172)
36        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invok
37e(ExposeInvocationInterceptor.java:89)
38        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
39ReflectiveMethodInvocation.java:172)
40        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
41cAopProxy.java:202)
42        at $Proxy118.checkEntries(Unknown Source)
43        at com.liferay.portlet.announcements.service.AnnouncementsEntryLocalServ
44iceUtil.checkEntries(AnnouncementsEntryLocalServiceUtil.java:249)
45        at com.liferay.portlet.announcements.messaging.CheckEntryMessageListener
46.doReceive(CheckEntryMessageListener.java:39)
47        at com.liferay.portlet.announcements.messaging.CheckEntryMessageListener
48.receive(CheckEntryMessageListener.java:31)
49        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
50        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
51java:39)
52        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
53sorImpl.java:25)



Can anyone tell me where i am going wrong?

Thanks for your kind support.
Saurabh Gupta
RE: Message Board threads sorting
October 5, 2012 5:33 AM
Answer

Saurabh Gupta

Rank: New Member

Posts: 23

Join Date: September 24, 2012

Recent Posts

@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