Community & Support

How can I Add Comment #NUMBER ?

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

$id - 4.7

in comment.tpl.php

<?php
print $id
?>

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

Exactly what I needed!!

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

Rosamunda

Rosamunda
Buenos Aires | Argentina

It does not work for the 2nd

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?

Same here... Wow, this is

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. :)

ID by date

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

Keep it Alive...

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
Buenos Aires | Argentina

Any ideas?

Any ideas on how to fix this?

Rosamunda
Buenos Aires | Argentina
www.ligadelconsorcista.org

Rosamunda
Buenos Aires | Argentina

No ideas in 3 years??

No ideas in 3 years??

I'm still curious how to do

I'm still curious how to do this either.

Similar stuff for Drupal 6.x

Solution for Drupal 5

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:

<?php
 
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:

<?php

    
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.

Hi, I can't understand the

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?

Everything I say is opinion, even if interpreted as fact.
Sometimes I may be inaccurate or *GASP* wrong!
Sometimes I attack Drupal due to frustration. Get over it.