Comment pagination is back. Sidebar link should still work.

Elwed dropped me an email with a solution to the comment links in the sidebar when using paginated comments problem so I’m trying it out. This means that the comments pages are once again limited to 25 per page to help speed up page rendering on the bigger threads. The sidebar recent comment list should still link directly to the comment regardless of which page it’s on. I’ve also updated the All Comments links to take advantage of the same solution.

The solution takes advantage of the fact that EE doesn’t really care what comment you start pagination with so we just stick a query in that counts the number of comments in the thread up to the one we want to link to and then we build a link with the pagination set to that number and it starts with that one and any other comments that come after it.

It’s pretty clever actually and I feel kinda stupid for not thinking of it myself.

Big thanks to Elwed for being more clever than I am.

3 thoughts on “Comment pagination is back. Sidebar link should still work.

  1. Something I noticed: If you terminate the link with /#comments, the behavior differs for threads with less or more than one page’s worth of comments.

    If you have more than one page of comments, the comment you’re asking for starts off the page and the page automatically scrolls to that comment. That’s just fine.

    If there’s less than one page of comments, the browser windowis positioned at the first comment and not the one whose link you clicked on. I think you can fix this by doing something like

    {if commentcount < 25}#c{comment_id}{else}P{commentcount}/#comments{/if}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.