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: 1112

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
    public List<MBMessage> getThreadMessages(long threadId, int status)
        throws SystemException {

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


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: 4830

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: 1112

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 ?!

    <sql id="com.liferay.portlet.messageboards.service.persistence.MBCategoryFinder.findByS_G_U_P">
        <![CDATA[
            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>
Hitoshi Ozawa
RE: Message Board threads sorting
May 24, 2011 3:25 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 4830

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: 1112

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

<?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">
        <![CDATA[
            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.