Comment Order

avatar deload Sep 10. 2009. 2:30 am
I had a look at config and searched this forum but could not find a hint of that feature. Please order all comments descending. The newest comment should always be on page 1, not on the last page. Pagination even makes this situation worse. So please change it.
avatar fdestors Pro Sep 10. 2009. 3:36 am
I totaly agree with you !
Comments should be ordered by most recent first
avatar wei.zheng163 Pro Sep 14. 2009. 1:24 am
Yes, it makes sense to arrange the comments in the chronalogical order so that the latest comment is always on the top, and the aged ones are at the bottom.

Anybody has any ideas? This should be an easy fix shouldn't it?

Regards,
--Wei
avatar Frederik (Dwarf) Pro Sep 14. 2009. 2:25 am
This can be changed in the following file:
application/modules/resources/models/comments/Comments.class.php

- Line 19 - 24:
    function findByObject($object, $min_state = STATE_VISIBLE, $min_visiblity = VISIBILITY_NORMAL) {
      return ProjectObjects::find(array(
        'conditions' => array("type = 'Comment' AND parent_id = ? AND state >= ? AND visibility >= ?", $object->getId(), $min_state, $min_visiblity),
        'order' => 'created_on',
      ));
    } // findByObject


And

- Line 36 - 41:
    function paginateByObject($object, $page = 1, $per_page = 30, $min_state = STATE_VISIBLE, $min_visiblity = VISIBILITY_NORMAL) {
      return ProjectObjects::paginate(array(
        'conditions' => array("type = 'Comment' AND parent_id = ? AND state >= ? AND visibility >= ?", $object->getId(), $min_state, $min_visiblity),
        'order' => 'created_on',
      ), $page, $per_page);
    } // paginateByObject


Change 'order' to:
        'order' => 'created_on DESC',


That should list comments from newest to oldest.
Best regards

Frederik Sauer
Dwarf A/S
avatar wei.zheng163 Pro Sep 14. 2009. 3:02 am
Frederik:

It seems to fix the problem. Thanks very much.

Best regards,
--Wei
avatar fdestors Pro Sep 14. 2009. 4:50 am
Frederik (Dwarf):
This can be changed in the following file:
application/modules/resources/models/comments/Comments.class.php

- Line 19 - 24:
    function findByObject($object, $min_state = STATE_VISIBLE, $min_visiblity = VISIBILITY_NORMAL) {
      return ProjectObjects::find(array(
        'conditions' => array("type = 'Comment' AND parent_id = ? AND state >= ? AND visibility >= ?", $object->getId(), $min_state, $min_visiblity),
        'order' => 'created_on',
      ));
    } // findByObject


And

- Line 36 - 41:
    function paginateByObject($object, $page = 1, $per_page = 30, $min_state = STATE_VISIBLE, $min_visiblity = VISIBILITY_NORMAL) {
      return ProjectObjects::paginate(array(
        'conditions' => array("type = 'Comment' AND parent_id = ? AND state >= ? AND visibility >= ?", $object->getId(), $min_state, $min_visiblity),
        'order' => 'created_on',
      ), $page, $per_page);
    } // paginateByObject


Change 'order' to:
        'order' => 'created_on DESC',


That should list comments from newest to oldest.



Thank you Frederik.
It works great. However, is there a way to keep the numbers of comments (#1 - #15 - number 1 being the oldest comment and #15 being the latest) ? In some discussion, we are referring to comments with their number...

Thanks for help
avatar Frederik (Dwarf) Pro Sep 14. 2009. 10:12 am
Hi fdestors,

Although it's possible it's a somewhat nasty hack imo. It's possible to make it nicer but then it has to be fixed in several files.

This hack is done in the following file:
activecollab/application/modules/resources/views/comments/_object_comments.tpl

- Line 14 - 15:
      
      {assign_var name=black_hole}{counter name=comment_num start=$counter}{/assign_var}


- Replace with:
      {assign_var name=arr_count}{$_object_comments_comments|@count}{/assign_var}
      {assign_var name=black_hole}{counter name=comment_num start=$counter+$arr_count+1 direction=down}{/assign_var}


As I said this doesn't look that nice code wise, but it works regardless of what kind of module the comments are attached to.
Best regards

Frederik Sauer
Dwarf A/S
avatar wei.zheng163 Pro Sep 17. 2009. 5:00 am
Frederik:

You solved the problem again. What a star!

Thanks,
--Wei
avatar fdestors Pro Sep 17. 2009. 5:11 am
Yeah ! thanks a lot !
avatar Guy C. Dev Oct 19. 2009. 2:19 pm
This works fine, but if there is a multi-page discussion, the Pages are not reverse ordered. Is there a way to also create the page order?
www.esolvesolutions.com
or Go To Next Page

Try activeCollab free for 30 days, No credit card required!

Instant access to activeCollab, no installation needed.

.tryactivecollab.com

If you are already a user of activeCollab, you can log in here.