Hello,

This is my very first patch and contribution ;-) Thanks to catch@drupal.org on http://groups.drupal.org/node/3466 for showing me how to do this.

It is a small change to the file \modules\views\modules\views_comment.inc on line 235:

/*
* Format a field as a number of comments, plus the number of unread comments.
*/
function views_handler_comments_with_new($fieldinfo, $fielddata, $value, $data) {
  $comments = intval($value);
  if ($comments && $new = comment_num_new($data->nid)) {
    $comments .= '<br />';
    $comments .= l(t('@num new', array('@num' => $new)), "node/$data->nid", NULL, NULL, 'new');
  }
  return $comments;
}

Changed to:

/*
* Format a field as a number of comments, plus the number of unread comments.
*/
function views_handler_comments_with_new($fieldinfo, $fielddata, $value, $data) {
  $comments = intval($value);
  if ($comments && $new = comment_num_new($data->nid)) {
   
    $new_ord = comment_num_all($data->nid) - $new;
    $per_page = _comment_get_display_setting('comments_per_page');
    $page = ($new_ord > $per_page) ? 'page=' . floor($new_ord / $per_page) : NULL;
   
    $comments .= '<br />';
    $comments .= l(t('@num new', array('@num' => $new)), "node/$data->nid", NULL, $page, 'new');
  }
  return $comments;
}

Which will make new comments' links link to the right page (on flat views).

I do not use this on my site myself any more, rather choosing to parse the views output in template.php because our users prefer to think of the very first node and all the comments as "posts" - one and the same. So I have to add new and totals up. Maybe views should output the data in stead of formatted lines in stead (url to new appart from count of new comments etc.).

CommentFileSizeAuthor
views_comment.inc__0.patch1.06 KBriaan burger

Comments

junyor’s picture

catch’s picture

Status: Needs work » Closed (duplicate)

Yes it is, and this'll be fixed in Views 2, but no 1.6 (or 1.5 for that matter). This is a duplicate of a patch I submitted - if I come across that will link back here.

maulwuff’s picture

great patch!