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 comments to Comment pagination is back. Sidebar link should still work.

  • I can’t take much credit for taking a hint from an unrelated post in the EE forums.

  • Funny how usually the simplest solution is the right one…

  • 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

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What is 13 + 10 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)