2

In Drupal 7, when theming the comments in my website (comment.tpl.php), I want to print the comment title without a permalink wrapped around as a link. I want the raw title. This should be simple, it seems, but it seems there is no variable for that. print $title will show the title wrapped with the permalink link.

Do I have to mess with template.php to fix that?

I also tried render($content['subject']), but nothing it is printed on the screen.

4

According to the documentation of comment.tpl.php, you should have access to $comment, so the following should work:

<?php print $comment->subject; ?>
5
  • It does not work. Actually, $comment->title is an array. Drupal prints "Array". But it is probably a good beginning. I had found that documentation too... Do you know how to go from there and get the raw comment title? Thank you. – Marcos Buarque Apr 29 '11 at 17:22
  • I meant to write $comment->subject, sorry. Anyway, I suggest you install devel.module if you haven't already. Then, you can simply do dpm($comment) and it will print all available keys in that object. – Berdir Apr 29 '11 at 17:38
  • Hi, thanks fot the hint... The $comment->subject also prints "Array", so I probably have to get some part of that array. I have Devel installed, although I am sometimes confused on the number of variables and interfaces in the Devel module... I cannot find the comment >> subject track, for example. Do you know where to find the comments? Can I find it in "Field info"? Thank you. – Marcos Buarque Apr 29 '11 at 20:52
  • print $comment->subject; works for me. – user1135 Apr 30 '11 at 22:10
  • ok, it works, you are right, I probably did something wrong when testing the first time... Thank you! – Marcos Buarque May 1 '11 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.