1

When comments are numerous on a node and you have a high comments per page setting, you have to scroll a lot to get to the pager. My users have requested pager at top as well as bottom of the comments list (not the top of the page) on a default node page.

To clarify

Current page layout

  • Title
  • Content
  • Comments
  • Pager
  • New comment form

The desired result is

  • Title

  • Content

  • Pager

  • Comments

  • Pager

  • New comment form

I've done this in the past in Drupal 7, but I can't figure out what template to use in Drupal 9.

I tried this code in field--comment.html.twig, without success.

{% if pager %}
  {{ pager }}
{% endif %}

None of the other templates in my theme seem to render the pager either, but has to be somewhere. I have Twig debugging on which provided some clues. I have checked page.html.twig, node.html.twig, and comment.html.twig as well as the field template. None of them seem to render the pager.

I feel like I'm missing something obvious, but obvious or not, I'm stumped.

1 Answer 1

1

The pager can be duplicated in the field--comment.html.twig if you correctly identify the pager (which I did not in the question).

{% if comments.pager %}
 {{ comments.pager }}
{% endif %}

Tested in my custom theme and also in Olivero.

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.