Show comment link function based on node comment settings and not user privilege I'm creating a custom theme and module for one of my content types. I want to show the comments link in a specific content type only if comments are turned on for the node or even globally for the content type specifically. I had originally used the following, simplified for example, in my tpl.php, which shows the link if the user has the privilege to comment. However, in my case, while I allow comments all over the site, I don't allow them on this particular content type. I want to leave the option open in case we do allow comments in the future.

&lt;?php
 if (user_access('post comments')) {
  print '&lt;a href="#"&gt;Comment&lt;/a&gt;';
 }
?&gt;


I was hoping that the system would recognize that a user that has privilege to comment every else still doesn't have privileges to comment on this node, and the link would not show, but it seems to show to anyone that has comment privileges, regardless of node.

What should replace user_access()?
If you look at https://api.drupal.org/api/drupal/modules%21node%21node.tpl.php/7.x

and click View source



and scroll down a bit, you will see that there is a variable that you can use:


  $comment: State of comment settings for the node.


So my guess would be that the value is either 1 (TRUE) or 0 (FALSE).

Using Devel module you can use Devel's dpm() function, so put:

dpm($comment); 


to dump and see it's value. 

If my guess is correct, then you would need to do something like this:

 if ($comment == 1) {
    print '&lt;a href="#"&gt;Comment&lt;/a&gt;';
 }