1

I am trying to figgure out how to show the comment form on its own page. So far I have been able to show it on a seperate page. All I had to do was to go to field comment setting and uncheck "Show reply form on the same page as comments"

So this allow the comments to show on a new page. The only issue is that the new page still shows body above. Is there any way to hide the body on the comment form page? enter image description here

Ideally I would like to load the comment form on a popup or modal. Can this be done with bootstrap modal or Colorbox inline?

1

1 Answer 1

2

You can accomplish this using an extra node template for the page where the comment form is displayed:

In your theme file create an extra template suggestion for the comment form:

function HOOK_theme_suggestions_node_alter(array &$suggestions, array $variables) {
    $route_name = \Drupal::service('current_route_match')->getRouteName();

    if($route_name === 'comment.reply') {
        $suggestions[] = 'node__commentform';
    }
}

Create an extra node template node--commentform.html.twig, and remove just about everything. You probably want to leave the node title, but otherwise there's nothing you need there:

<article{{ attributes }}>

  {{ title_prefix }}
  {% if not page %}
    <h2{{ title_attributes }}>
      <a href="{{ url }}" rel="bookmark">{{ label }}</a>
    </h2>
  {% endif %}
  {{ title_suffix }}
</article>

The comment form is rendered outside this template, so you don't need any of it.

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.