2

I'm currently using the following line of code in my comment.tpl.php file:

<?php print render($content['links']) ?>

This also prints the 'Reply' link, but I'd like to remove that one. How can I do that?


Note: I'm able to hide the 'Reply' link with CSS, but that's not a very nice solution.

4

If you wanted to remove all links, you could do it in a template file like this:

hide($content['links']);
print render($content);

But I don't know how to hide just the comment reply link this way. Based on a short article here, it looks like you can unset the reply link with a preprocess function in template.php like this:

function themename_preprocess_comment(&$variables) {
  unset($variables['content']['links']['comment']['#links']['comment-reply']);
}
  • I expected that the problem could be solved within the template file, but this preprocess function works all the same. Thank you! :) – Jeroen Oct 2 '14 at 20:21
2

I think you should be able to change this behavior by modifying the comment settings for each content-type. This could be done by going into admin/structure/types/manage/<your-content-type>, scroll down and click on comment settings in the left menu. In the settings form you then uncheck the box next to Show reply form on the same page as comments.

Comment Settings

The above doesn't seems to work, but you could easily make a small module and implement hook_comment_view():

function <YOURMODULE>_comment_view($comment, $view_mode, $langcode) {
  unset($comment->content['links']['comment']['#links']['comment-reply']); 
}
  • Thanks for your answer. I unchecked the box you mentioned, but that doesn't work for me. – Jeroen Oct 2 '14 at 20:17
  • @Jeroen - I noticed that the above didn't do what I expected and therefore updated my answer with a working solution. – Cyclonecode Oct 2 '14 at 20:23
  • Thank you for your quick reply and update! Is working with hook_comment_view more appropriate than hook_preprocess_comment according to you? I'm not an expert in these kind of things... – Jeroen Oct 2 '14 at 20:31
  • 1
    No, I think both will work. The only thing was that I couldn't get hook_comment_view() to work in the theme so I was forced to add it into a small custom module. If you are able to use hook_preprocess_comment() in your template file I would stick with that. – Cyclonecode Oct 2 '14 at 20:35

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.