I'm improving a WordPress theme with PHP. The theme contains a gallery section which loads data from the Flickr API.
Now the client wants to display Flickr galleries as well as "local" galleries without disclosing where a particular gallery is loaded from.
On page load the theme does a Flickr API request loading 6 galleries. When a "load more" button gets hit, the theme requests 3 more galleries.
I can do exactly the same for for local galleries.
To merge them, I could put them into a unified data structure and order by a "date created" timestamp.
The problem is, after the merge, I don't have any clue how many items come from which data source and which page I need to request from each source when attempting to load more.
I, somehow, need to ensure I'm not leaving out any gallery or display it multiple times. How can I get around this issue? What would be the conceptual ideas you guys would come up with?
EDIT
The big problem here is, that I need to work with PHP and cannot store a bunch of entries in an array across requests and load new data if needed. I could only pass a few arguments around, like page numbers, counts; stuff like that