What are some ways of rendering a comment form without also displaying the comments?
What about creating a block contains the form? If that's possible, what are some links to documentation touching on that?
To display comment form without comments list, you need to override field--comment.html.twig
template, and remove the following lines:
{% if comments and not label_hidden %}
{{ title_prefix }}
<h2{{ title_attributes.addClass(title_classes) }}>{{ label }}</h2>
{{ title_suffix }}
{% endif %}
{{ comments }}
to override it:
field--comment.html.twig
content without the above section.
* field--node--comment--article.html.twig
* field--node--comment.html.twig
* field--node--article.html.twig
x field--comment.html.twig
x field--comment.html.twig
* field.html.twig
Note: the above suggestions for article content type, you may have different suggestions.
/**
* Implements hook_theme().
*/
function MODULENAME_theme($existing, $type, $theme, $path) {
return [
'field__node__comment__article' => [
'base hook' => 'field'
],
];
}
And make your changes in MODULENAME/templates/field--node--comment--article.html.twig
hook_theme()
.