By held69 on
I like to add a comment number for each comment in my theme.
This function can also be seen drupal.org its self?
or such as
#1
comment blah blah etc.
sofia
#2
second comment blah blah lorem ipsum
jason
#3
again some comment bla blah
mark
I have found a thread about this subject but it doesn't seem finished.
http://drupal.org/node/69287
Thanks
Comments
I found the answer by searching
But unfortunately can't find the threads now I that I want to help close unanswered leads.
But in the interest of not leaving questions unanswered I'll try to explain what I found to work for me (Drupal 6.13). Apologies for formatting and explanation errors.
First I disabled Comment subject field in the comment settings of the content type
then in comment.tpl.php commented the $title, printed the $id and incremented it
easy
Note, as pointed out in http://drupal.org/node/69287#comment-726966 it numbers the comments in the order they are shown on the page, not by date added.
And also I have all comments on one page.
For adding comment numbers further pages I saw http://drupal.org/node/169964 but haven't tried it.
That increment you are doing
That increment you are doing doesn't have any effect. The id is already incremented when it is made available in the template.
Here is a fix for both order types (newest first and oldest first) and paging. Put this in a module.
Then you can use $id in comment.tpl.php.
Think it should work without any problems.
[edit] Only tested with COMMENT_MODE_FLAT_COLLAPSED and COMMENT_MODE_FLAT_EXPANDED
Thank you for your
Thank you for your replies.
It looks a bit complicated as i'm not much of coder,
but I'll have a look at it.
It's not that complicated.
It's not that complicated. You can either put that code in a module or you can have it in your theme's template.php file (proberbly the best if you're not familiar with coding) but then you'll have to change the function name from
MyMODULE_preprocess_commenttoMyTHEME_preprocess_commentwhere MyTHEME is the theme you are using.Then you'll just have to add
<?php print $id; ?>some where in your comment.tpl.phpthanks! for your clear
thanks! for your clear tutorial.
I'll give it a shot and report.
Still some problems
First of all thanx for your piece of code.
Hi i have the same issues with numbering the comments.
I have added your piece of code to the files, just as explained in the thread.
Everything seems to work fine; oldest first and newest first both work.
But if there is a second page the numbering jumps back to 1 and starts counting up again.
Did i implement you code wrong??
Then the function is not
Then the function is not called. If you try and print something inside that function and it gets printed on the top of the page then you know it gets called. Just put
print 'inside';inside the function and above the other code.If you have the theme garland the function should be named
garland_preprocess_commentand be placed in template.php.Working fine, still one question though
I implemented your code again, and now working fine (probably made mistake, still quite newbie with php)
one thing though: when i click the reply button on comment 14 for example it prints:
Reply to comment 1
"Subject"
"comment"
It does reply to comment 14 though, is it possible to change this into?
Reply to comment 14 (the correct comment number)
"Subject"
"comment"
This happens when i sort "date oldest first".
When i sort "date newest first"
It will always print
Reply to comment 15 (the newest comment)
So it seems it will always display the first comment number when making a reply.
There is no way for drupal to
There is no way for drupal to know what #id that comment has when loaded on comment/reply/. As it is now you would have to get all comments for that node from db and calculate what id it has.
This is also true for paging links. There was a discussion here http://drupal.org/node/26966 about it. Its a known "bug" and as it seems it will not get fixed for drupal 6.*.
drupal.org??
So drupal.org self, uses a db query to display the comment number in the reply??
Thanx for your help
drupal.org doesn't have #id
drupal.org doesn't have #id displayed on comment/reply?
Sometimes it does
The thread you send about the same subject http://drupal.org/node/26966
If you reply any comment in that thread it will show the #id on the reply page
http://drupal.org/comment/reply/26966/335951 for example
subscribing
subscribing
too
too
Open Atrium guys figured it out
The Ginkgo theme of Open Atrium (a Drupal installation profile) has this functionality. See it live at this url for instance: https://community.openatrium.com/issues/node/52.
I looked at OA files to see how they did it and will be hacking my own theme to mimick it. I am sure real programmers with some time at hand could turn this into a module though.
You can download Open Atrium and look into the folder profiles/openatrium/themes/ginkgo to locate template.php. Look for "function _ginkgo_get_comment_decay" in there.
For a quick preview you can see this github page I found through a Google search (= file likely to be modified by now):
http://github.com/ianshward/ginkgo/blame/master/template.php
blog post
I found a post on the planken.org blog on sequentially number comments across pages that was useful. In the end, I borrowed some code from the Advanced Forum module, which does something similar.