I´ve seen in a lot of sites (and I want to emulate them :-) that the comments are numerated. In example:

#1
Comment by Andy on Sat. 14.02.2006
bláh bláh

#2
Comment by Samir on Sat. 14.03.2006
bláh bláh

#3
Comment by Andreas on Sat. 20.03.2006
bláh bláh

And so on and on...

How can I do that?

I know that maybe I solud add/modify something at the comment.tpl.php template... but what??

Thanks in advance!!!

Rosamunda

Comments

Suzy’s picture

in comment.tpl.php

print $id

this is 4.7 ~ can't remember what it used to be

Rosamunda’s picture

Thanks!!!! Just what I needed!
It works perfectly.

Rosamunda

zigma’s picture

It does not work for the 2nd page. It seems $id is initialized for each page. Therefore on 2nd page and thereafter $id does not reflect correct comment number.

Has anyone been able to get this working?

roper.’s picture

Same here... Wow, this is pretty old, as with the bug of permalinks on pages other than the first; that one's 3 years old. What the hell man...

Would like a fix for this please. :)

justin3’s picture

another prob is that the comment # is not ordered by date, but by how it's listed on the page. For instance, this would be the 5th comment posted, but since it's a reply to a higher comment, it shows up higher and would print $id would show as comment #4 ....

well not exactly on this thread because all the comments are replies, but on other pages the prob materializes

Rosamunda’s picture

Yeap! Keeping this alive to see if someone can help about the second page issue...
And how it would be with 5.x ...

Rosamunda
Buenos Aires | Argentina
www.ligadelconsorcista.org

Rosamunda’s picture

Any ideas on how to fix this?

Rosamunda
Buenos Aires | Argentina
www.ligadelconsorcista.org

kakarot-1’s picture

No ideas in 3 years??

held69’s picture

I'm still curious how to do this either.

Feet’s picture

kayceedub’s picture

Reusing some of the code from that Drupal 6 thread, I put the following in my comments.tpl.php file (for my Drupal 5 site):

At the top:

  if (!empty($_GET['page'])){
  	$commentsPage = $_GET['page'];
	$comments_per_page = _comment_get_display_setting('comments_per_page', $variables['node']);
	$commentID = $commentsPage * $comments_per_page + $id;
 	
  }else{
  	$commentID = $id;
	
  }

Then to call the number in your template:

     print $commentID;

I know it's not ideal to put that first php part into the template but i wasn't able to get template.php to utilize the $id variable.

-Anti-’s picture

Hi,

I can't understand the script - I don't know any php.
It appears that this would be fine with flat comments and work across comment 'paging'.

But would it work with threaded comments?
Is numbering only really practical with flat comments?

grn’s picture

Just wanted to close this thread.

In Drupal 7 we can use https://drupal.org/project/comment_easy_reply to achieve this. I found this case, when I was searching for this function.

Thanks.

MickC’s picture

Someone might find this useful - modified comment.tpl.php in D6 and copied to theme:

<a href=<?php print '"#comment-' . $comment->cid . '"' ?>><?php print '#' . $id . ' ' ?></a><?php print $title ; ?>

MickC’s picture

sorry - dupe posting deleted...

madeltoro’s picture

Thanks bro, works on D7 too

michaellenahan’s picture

/**
 * Preprocess comment.
 */
function THEMENAME_preprocess_comment(&$vars) {
  // Add #CommentNumber to comment title.
  if (!empty($_GET['page'])) {
    $comments_page = $_GET['page'];
    $node_type = $vars['elements']['#node']->type;
    $comments_per_page = variable_get('comment_default_per_page_' . $node_type);
    $comment_id = ($comments_page * $comments_per_page) + $vars['id'];
  }
  else {
    $comment_id = $vars['id'];
  }
  $vars['title'] = '#' . $comment_id . ' ' . $vars['title'];
}
sanmikele’s picture

thanks michaellenahan, worked for me.