I am helping a client with a WordPress template that is using Isotope.js in a masonry layout.
Isotope.min.js: http://isotope.metafizzy.co/ or source code here: http://isotope.metafizzy.co/jquery.isotope.js
The base template: http://themetrust.com/demos/ink/
The problem is that they have hundreds and hundreds of items that will need to be in that portfolio so displaying them becomes an issue. Obviously we don’t want all of them to load at once. Even with some form of lazyloading integrated, it would still be a massive size.
QUESTION: Would it be possible to alter Isotope to include some kind of pagination? Maybe a “click here to load more” div along the very bottom that then loads the next batch of items? Or even better – something in the main loop so that every 20th block just says “Load More Items” and clicking it replaces those first 19 items with the next 19 items (19 items + the Load More block so that there is always a grid of 20)?
Basically, I’m just trying to figure out the best way to still use Isotope (so we don’t have to completely redo sections of the template the client likes) but have it incrementally load it’s items so that load times and page size are adversely affected. Any help would be greatly appreciated!
I faced the same issue and finally managed to add pagination to isotope. Though my solution works, it is not helpful when managing large data, since all data is loaded and consequently filtered.
First, I divided all my content into pages and assigned matching css classes (page1, page2, page3, …) to each item. Then I added pagination to the frontend and I set the matching filter with JavaScript. Here are some code examples from my TYPO3 Extbase setup:
PHP in Controller to calculate css classes for page filters:
With this code, I had all the needed css classes calculated.
HTML in template
In the HTML code I assigned the CSS class to each item, which has been calculated in the controller by using
<div class="item {project.pageClass}">...
Then I added the HTML-Code for the pagination:
JavaScript
Finally, I just needed the following JavaScript, to make the pagination functionable with isotope (all JS, no reloading of the page necessary!):
Like I said this comes from a TYPO3 context. I implemented this code in a custom extension based on extbase. These code fragments won’t be portable to other projects without adjustments, but I hope they will still be helpful.