By sleddoggin on
Hello,
On each page above the commenting area I would like to write something like "53 Responses to "title of the article goes here"". My problem is I can't figure out the variable to call upon for the total amount of comments for that story.
I would write something like print $number_of_comments ; Responses to " print $title ;"
Any thoughts or help would be great!
Thanks!
Comments
$comment_count
If you look at the comments at the beginning of the default node.tpl.php template, you will see what variables are available to your theme node.tpl.php template. (Provided you have a PHPTemplate theme...)
So go to modules/node/node.tpl.php. Look at the 'header' of the file.
Looking at 'Other variables' you will see:
So the variable that gives you the total amount of comments is $comment_count.
Now to print that value in your theme's node.tpl.php file, just do this:
print $comment_count;If you write this in a sentence, you might be interested in using some logic.
You might want to look at the function http://api.drupal.org/api/function/format_plural/6
Caroline
11 heavens.com
Complete code would be
You might include an 'else' statement, to encourage people to be the first to comment on the subject...
Caroline
11 heavens.com
Wow, thank you for the quick
Wow, thank you for the quick replies. Each day I seem to enjoy Drupal more and more - and fall in love with the awesome community.
Here's an example of what I've implemented thus far: http://sleddoggin.com/mushing-news/researchers-seek-demystify-metabolic-... (just scroll down to see the comments area)
Thanks again; I'm learning so much about Drupal through the boards - and am starting to feel much more confident in designing a site through Drupal.
WOW!
Exquisite web site.
Great work!
I saw the comment area too. Your little touch there, with the number of comments in a sentence, just above the comments, that is real good.
Caroline
11 heavens.com
Thank you for the comments -
Thank you for the comments - glad you like my website! And thank YOU for your help!