stopping infinite scroll
3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 7, 2016 (RSS)
By squeazel - June 6, 2016
I'm loading records using the infinite scroll jquery plugin. It automatically increments the page= at the end of the URL until it gets a 404. However, cms builder returns the last available page of records not matter how high the page number is. As a result, the last set of records loads over and over. Is there any way to force a 404 instead? Or, has anyone come up with another workaround? thanks, Jason
By Damon - June 7, 2016
Hi Jason,
I'm not sure how the infinite scroll jquery plugin works but you could start with code like this:
<?php if($newsMetaData['totalPages'] < @$_REQUEST['page']) : ?>
Go to 404
<?php endif; ?>
The $newsMetaData['totalPages'] is the total number of pages. Change the name to match your section editor name.
The @$_REQUEST['page'] is grabbing the page number from the URL. The @ symbol suppresses errors if there isn't a page variable to get.
Not sure if you need to redirect to a 404 or something else.
Let me know if this works for you and which infinite scroll jquery plugin you are using.
Thanks!
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
By squeazel - June 7, 2016
Thanks Damon! I wrapped my entire code displaying the CMS records inside your code, but changed it to >= instead of <, and it worked.