反時間方向的留言排序

Drupal 原生在 node 下的留言是使用時間最先的開始 (created ASC)
但如果需要反方向的話 (不使用 views 為前提):

<?php
/* Implements hook_query_TAG_alter().
https://www.drupal.org/node/1095656#comment-7885467
* * Alter comments query to order by DESC as well as the default ASC. */
function CUSTOM_query_comment_filter_alter(QueryAlterableInterface $query) {
 
$orderby = &$query->getOrderBy(); 
 
$expressions = &$query->getExpressions(); 
 
// Sorting for threaded comments.
 
if (isset($orderby['torder'])) {  
   
// Get rid of the expressions that prepare the threads for ASC ordering.
    // Simply order by the thread field.
     
   
unset($expressions['torder']);
    unset(
$orderby['torder']);
   
$orderby['c.thread'] = 'DESC';  
        
      
  }else{ 
// Sorting for flat comments.  
   
$direction = 'DESC';
    if (isset(
$orderby['c.cid'])) {
      unset(
$orderby['c.cid']);   
    }
   
$orderby['c.created'] = $direction;
   
$orderby['c.cid'] = $direction;
  }
}
?>

意外地繁瑣。還是使用 views 吧...

Google