Infinite Scroll with Kirby

Hi, I am attempting to use jquery infinite scroll plugin on a collection of sub pages of a News (Blog) page.

Infinite scroll is configured to die when it hits a 404 Not Found status code, so when it goes through all your archives it should hit a /page/43/ (or something) that doesn’t exist, then show a message “Congrats, you’ve reached the end of the internet.”

It is working fine except when the plugin tries to load a page that doesn’t have any more posts (e.g. my-site/blog/page:69) it appends the posts from the last available page instead of returning a 404 page and thus kill infinite scroll. This results in the plugin never stopping loading posts.

with the standard kirby pagination if i try go to a link such as my-site/blog/page:9999 or something which i know definitely doesnt exist, it just gives me the last post or set of posts.

is there a simple way to configure the pagination to work in this way ??

Thank you :smile:

1 Like

I wonder if it’s got to do with this issue: https://github.com/getkirby/kirby/issues/251

(ex: http://laudableapps.com/):

    <?php if($articles->pagination()->hasPages()): ?>
    <nav class="pagination">
    
      <?php if($articles->pagination()->hasNextPage()): ?>
      <a id="next" data-site="<?php echo $articles->pagination()->nextPage() ?>" data-href="<?php echo $articles->pagination()->nextPageURL() ?>">Show me more Apps</a>
      <?php else: ?>

      <p>Congrats, you’ve reached the end of the internet.</p>

      <?php endif ?>
    
    </nav>
    <?php endif ?>

Yes ?

no sorry, because the page is never refreshed, the link is never updated, when you load the first page the nextpage link is always my-site/blog/page:2 - this works with infinite scroll plugin and loads in the correct content , all the way till the end then just keeps loading in the last page over and over

I don’t know how the plugin works, but I think what you need to do is check how many pages you have in the first place and then compare the number passed in the request against the number of total pages in your script.