1

I've installed the AJAX Comments module in my Drupal site.

Am unable to find the configuration to remove the reply Link from the comment reply, kindly suggest.

Attaching a screenshot below: enter image description here

1 Answer 1

4

You can implement template_preprocess_comment() in your module file or theme's template.php file. And check if comment has Parent Comment ID (pid), if yes then remove reply link.

/**
 * Implements template_preprocess_comment().
 */
function [MODULE/THEME_NAME]_preprocess_comment(&$variables) {
  $comment = $variables['elements']['#comment'];
  if (!empty($comment->pid)) {
    unset($variables['content']['links']['comment']['#links']['comment-reply']);
  }
}
8
  • vote up . this is good solution
    – Yuseferi
    Aug 26, 2016 at 8:09
  • it is not working for me. Aug 26, 2016 at 8:50
  • What error are you getting? Did you try clearing cache after implementing above hook?
    – Yogesh
    Aug 26, 2016 at 8:54
  • sorry i forgot to clear the cahce.it's working perfectly fine.and one more thing is it possible to we can use this same hook to hide some field values in indented comments right? Aug 26, 2016 at 9:00
  • Yes, we can. You can also use this hook to add new fields to show in comment, but for that you'll need to override comment template file (.tpl.php) and print new variable.
    – Yogesh
    Aug 26, 2016 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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