getResources infinite scroll - is it possible?

Hi all,

I’m using getResources to pull in a load of results based on some defined criteria… I’d love to implement a way to tell getResources to pull lets say 20 results at a time, so in effect use pagination - but rather than have the pagination link to new pages, stay on the same page and load in results below the previous 20… I’ve looked at the examples I can find online, but none of them seem to work for me? I was wondering if anyone had a good example somewhere I could follow to try and implement the solution? I guess I need an Ajax call to call 20 results at a time to be displayed some how… any ideas?

Ideal solution would be to not even had a load more button, and fire the AJAX call to bring in the next 20 results when the user scrolls to near the bottom of the current 20

1 Like

There’s a JQuery example here that you might be able to adapt.

You could use $modx->runSnippet(‘getResources’, $params) using limit and offset in the processor.

I would do it with a button at first before trying to adapt it to load automatically on scroll. Here’s some code for that.

1 Like

you could also switch to pdoTools and use pdoResources with pdoPage.
It has build-in ajax-mode

https://docs.modx.pro/en/components/pdotools/snippets/pdopage#Load-on-scroll

1 Like

Thanks Bruno - I am so far down the getResources avenue I will have to flog that horse a little more first… if that fails - will look at pdoTools - I assume I can do all the fancy getResources as per other forum post on pdoTools like I am with getResources?

1 Like

Thanks Bob. Not sure I have the skills to work out how to take this none MODx solution and apply the logic… will have a go…

1 Like

Managed to get it working using https://forums.modx.com/thread/97882/getresource-display-x-items-needed-for-load-more-functionality#dis-post-533778

1 Like

Nice, good find!! There are so many gems in the old forums

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.