Opening this up since I'd like to help if possible and it was mentioned in the wiki.
http://drupal.org/node/6162#comment-296152 for a quick link to the closest thing available.

Looks like it might be possible to do this with:
template.php
comment_new_page_count in a module
hook_link_alter maybe?

- also our forum users use the tracker loads - so we hacked that as well :| - might be possible to make a new views handler which can replace "comment count with new link" to do that more cleanly in order to get this running as well.

Another thing is once you have the comment_new_page_count function - you can make posted comments page return back to the page they were posted from instead of node/123#comment-456 all the time (in flat expanded, most recent last at least). This also got into 6.x, makes a big difference.

In D5 we just used:

comment_form_submit:

-    return array('node/'. $form_values['nid'], NULL, "comment-$cid");
+  return array('node/'. $form_values['nid'], "page=".comment_last_page($form_values['nid']), "comment-$cid");

although that was with our fugly version which never got patchified.

Comments

satos’s picture

catch, do you know what changes need to be done to make normal links in 'Recent comments' block? I'm using patch from http://drupal.org/node/6162#comment-296152 , tracker and forum generate nice links to the new comments, it will be good to have such links in 'Recent comments' block.

Michelle’s picture

I'va had that old thread open in a tab for days but haven't had a chance to work on backporting it. I need to work on a client site for a bit before I do any more active dev on the module. Will take another look at it then. Thanks. :)

Michelle

satos’s picture

Well, I spent some time trying to get 'Recent comments' block work, but it still don't show links properly.
Here is the code:

Add to the comment.module:

function _pages_count($nid)
 {
    $pages = 0;
    $count = comment_num_all( $nid );
    $per_page = _comment_get_display_setting( 'comments_per_page' );

    if( $count > $per_page )
    {
        while( $count > $per_page )
        {
            $pages++;
            $count -= $per_page;
        }
        return 'page='.$pages;
    }
    else
    {
        return NULL;
    }

}

Changing some code within function theme_comment_block();
(just adding function call instead of the second NULL):


function theme_comment_block() {
  $items = array();
  foreach (comment_get_recent() as $comment) {
   
    $items[] = l($comment->subject, 'node/'. $comment->nid, NULL, _pages_count($comment->nid), 'comment-'. $comment->cid) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
     }
  if ($items) {
    return theme('item_list', $items);
  }
}

The problem is that page number in the link is always = the max № of pages in the node:

If we have 3 page of comments, it always print
/node/4?page=2#here_we_have_comment_number

And even if the comment is on the first page (page=0), it still prints
/node/4?page=2#here_we_have_comment_number

I think function _pages_count should be changed somehow to always print page which belongs to the comment in the 'Recent comments' block.

Any ideas?

catch’s picture

satos: yes it's very hard to know the actual page that any particular comment lands on - that's why the node/6162 patch still relies on #new. I'd look at the final patch that got committed to drupal 6 and see if you can adapt that since it deals with threading and the rest. I'm not convinced there's anything in it which deals with this particular issue though.

What you might be able to do is use the comment_pages module (or comment permalinks, or whatever it's called) and then link to the urls generated by that - which are something like example.com/comment/1234 - I haven't ever looked at that module though beyond the release announcement. Obviously those will be out of context of your discussion though (unless there's changes I dont know about which is likely).

Michelle’s picture

re the comment page module: I actually have that installed on the dev site but it's blocked on this issue. I had intended to put the link right next to the comment number as a permalink but can't figure out where the module is going wrong.

Michelle

catch’s picture

Personally I'm holding off comment page until there's genuine core permalinks for comments, partly because to avoid module bloat, partly in case of link rot - ie. when comment permalinks end up as node/123 ;) For new comments blocks, I just create a tracker-style table view with node title and comment count/#new link.

Michelle’s picture

Status: Active » Closed (won't fix)

This is fixed in 6.x and I've decided it's just not worth the effort to try and backport.

Michelle

Michelle’s picture

Status: Closed (won't fix) » Fixed

LOL! I just realized while trying to fix another issue that I actually did backport this without realizing it. It was part of other code I backported. So I guess it's fixed. :)

Michelle

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.