Add the "Add comment link" and/or "(2) Comments" link

Asitis - July 11, 2008 - 13:32

Hey,
I'm working on a project for a big Drupal based site, including a totally custom made layout. I've based this layout upon Grid Inspired ( http://drupal.org/project/grid_inspired ).
It all works swell, except for the fact I can't figure out how to add "Add a new comment" link to the end of each post.
In Wordpress there is a simple template tag for this (something like 'get_comments'), and Im not really that experienced with Drupal..
Is there any kind of (easy) way of adding such a link to the end of each post?

I found out other themes had such links, but I cant figure out where or how they are called..
Thnx

Well, you can print the

Jeff Burnz - July 11, 2008 - 21:15

Well, you can print the links variable:

<?php
if ($links) {
print
$links;
}
?>

Or you can just print the link to the comment form, something like this:

<a href="http://example.com/<?php print $node->links['comment_add']['href'] ?>" title="<?php print $node->links['comment_add']['attributes']['title'] ?>">Add your comment</a>

does this code deal with all

bjraines - August 28, 2008 - 03:37

does this code deal with all the permissions of viewing comments as well?

That's a link to the comment

Jeff Burnz - August 28, 2008 - 09:34

That's a link to the comment form, for adding a comment.

To control the viewing of comments, such as preventing anonymous users from viewing comments, set the permissions in User Management > Access Control.

In any case the snippet is just printing what is already available in the node, so if its not available, nothing should print.

what would you do to show

bjraines - August 28, 2008 - 11:55

what would you do to show how many comments a node has already?

 
 

Drupal is a registered trademark of Dries Buytaert.