3

I am trying to work out how to change the order of a flat list of comments in Drupal 7. It seems that comments are listed in chronological order with the oldest appearing at the top and newer ones appearing further down. Is there some way of reversing this order so that the most recent comments appear at the top and older ones at the bottom?

There is a module called sort_comments but there is no official release version (only dev). The constraints of the project I am working on does not allow the use of non-production ready modules.

Project constraints also prevent the use of any custom modules. Only allowed to customize at theme layer (e.g. can create custom theme).

1
  • 2
    There is a thread in talking about this drupal.org/node/1095656. Another alternative would be to display the comments using views. – No Sssweat May 20 '15 at 9:22
1

You could use Comment goodness it has a stable D7 release.

Provides comment sorting, comment form placement and comment form configuration settings.

1

Here is a simple way if you don't want to use Comment goodness, Use array_reverse to reverse comments array in tpl.

  1. Copy modules/comment/comment-wrapper.tpl.php into your custom theme with the same name.
  2. Change this code print render($content['comments']); by:

 $comments = array_reverse ($content['comments']);
 print render($comments);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.