Discussion pagination in elgg 1.8 is not working properly

77 Views Asked by At

We have a website created using elgg, and we have discussion part of elgg where pagination is not working properly.

When listing all discussion list, pagination is working correctly, from latest to oldest

But pagination inside topic (one of the discussion) where replies are too many, and they separated by pagination (Previous, next), it is showing replies incorrectly:

In the first page we have: The first page

As you can see it is ordered from latest to oldest: 17 days ago and then comes 21 days ago.

But when you go next page: Page 2

It is ordered inside the page from latest to oldest, but the the pages should be swapped.

How can I fix it?

Thanks forward

2

There are 2 best solutions below

0
On BEST ANSWER

I have found finally going through all pagination libraries, and annotation views.

The problem is when listing replies for discussion on replies.php file which in /views/default/discussion there are two jquery functions on the bottom of the page that reverse the order.

function reverse(arr){
    var newArr = [];
    for(var iter = arr.length -1; iter >= 0; iter--){
        newArr.push(arr[iter])
    }

    return newArr;
}

I have change the iter to start from 0 and go to arr.lenthg.

But it is not all yet, in order to get the latest replies first, I have added to

$options = array(
'guid' => $vars['entity']->getGUID(),
'annotation_name' => 'group_topic_post',

);

this line:

'order_by'=> 'time_created desc'

And then I got my replies ordered correctly: from latest to oldest.

2
On

It works properly. Discussions are ordered by last action on the thread. You may have older thread first due to it having most recent response of all threads.

To change it, look at discussion_handle_list_page function in mod/groups/lib/discussion and how it uses order_by parameter. You need to override this page and just remove order_by to use default ordering, which is creation time of the entity (in his case thread). You could do it by tapping to the "route" plugin hook, or overriding whole discussions page handler.

And that's why not just change it inline: http://learn.elgg.org/en/1.9/guides/dont-modify-core.html