How can you remove the reply button under each comment in Drupal 8? I understand there is an option "Show reply form on the same page as comments", but I am not trying to remove this form. Only the reply button.
How can the reply button be removed?
You could use the hook_comment_links_alter()
use Drupal\comment\CommentInterface;
/**
* Implements hook_comment_links_alter().
*
* Unsets the "Reply" link of a comment.
*
* @param array &$links
* A renderable array representing the comment links.
* @param \Drupal\comment\CommentInterface $entity
* The comment being rendered.
* @param array &$context
* Various aspects of the context in which the comment links are going to be
* displayed, with the following keys:
* - 'view_mode': the view mode in which the comment is being viewed
* - 'langcode': the language in which the comment is being viewed
* - 'commented_entity': the entity to which the comment is attached
*/
function mymodule_comment_links_alter(array &$links, CommentInterface $entity, array &$context) {
// Unset the "Reply" link
if(isset($links['comment']['#links']['comment-reply'])) {
unset($links['comment']['#links']['comment-reply']);
}
}
Go to Structure >> Comment types and under Manage display, move "Links" to Disabled section.
Save and the Reply link for each comment will disappear.
The forms in Drupal 8 are entities, through the administration of the form you can manipulate the fields and in the presentation of the type of content you can show it, the button can be deleted from the entity of the comments.