Score:1

How can I render comment pager on the top and the bottom of the comments portion of the page

pe flag

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.

Score:1
pe flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.