0

I've added a comment field to my content type. Now I'd like to add infinite scroll to the comments messages, so it shows by default some number of comments and when I click on the load more button, it shows more.

The problem is that the list of comments is coming from the comment module, not a view, so I can't add infinite scroll plugin to the pager. If I create a custom view that shows the comments, it gets complicated because some comments have nested comments and so on. Is there any solution?

0

One option is to create a "views block" that shows comments, set it to use views infinite scroll, then add it to the bottom of the page (and disable the page from showing comments the normal way).

  • Matt, thanks. setting a new view "as block"that display comments and adding infinite scroll as pager. And render it at the bottom it's easy.Then i'm confused what do you mean and disable the page from showing comments the normal way ? how to make the list of comments comming by default from comment module related to my custom view ? once a agian i cannot configure that list coming from the comment module, its not even a view. – Rached Nemr May 14 '19 at 21:57
  • Two potential ways I could imagine: 1. You might be able to do it through the drupal UI. If you go to the content type you're dealing with and "manage display", does it allow you to hide comments? 2. You do it with a theme override. First turn on twig debugging (drupal.org/docs/8/theming/twig/debugging-twig-templates) then view source of the page to see which twig template is showing comments. Then, you can override that template by creating a template with the same name in your subtheme. Simply copy the original template over, but remove the part that displays comments. – Matt May 15 '19 at 9:36
  • There's a 3rd rather dirty way to do it, which is to hide the normal section that shows comments with CSS (display:none). I wouldn't recommend this way as it's not great for performance but it is a 3rd option. – Matt May 15 '19 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.