Hello everybody,

I'm taking my first steps into modifying existing themes. On http://jstarek.de/ I use Roopletheme's LiteJazz theme as a basis. In order to have comment counts shown below blog posts (like Wordpress et al. do it), I edited the theme's node.tpl.php to include

<?php if ($links) { ?>
<div class="links">
      <!-- only the following line was added -->
      <?php print "<a href=\"".$node_url."\">".$node->comment_count." Kommentare"."</a> &nbsp;&emdash;"; ?>
      <?php print $links?>
</div>
<?php }; ?>

I have two problems with this:

  1. The line with the comment numbers is shown for all blocks, even those where I have comments disabled. What property can I check in order to have it appear only for nodes of a specific type (in my case, blog posts) or only for nodes where commenting is allowed?
  2. How can I make the word "Kommentare" translatable?

Many thanks in advance!

Jürgen

Comments

francort’s picture

1.- you're checking that the node has links, then if it has any link (such as taxonomy), the link will apear
2.- to make text translatable, use t() function( see drupal api for detailed reference )

it is better to create links with l()function
the code would be like this:

// node should have comments enabled and user permission to read them
if ($node->comment == COMMENT_NODE_READ_WRITE && user_access('access comments)) {
    print l($node->comment_count.t(" Kommentare"), drupal_get_path_alias($node->nid));
}

i hope this will help you :)

good luck!!!

jstarek’s picture

Thanks for your hints! Meanwhile, I also finally discovered where the complete function reference for Drupal is located (namely, http://api.drupal.org/api/functions/5 ) and with the help of that info, I think I'll get ahead.

Regards,

Jürgen