Hi
I just need some advice on the best way to achieve this. The setup I have is:
Items
Item 1
Note 1
Note 2
Note 3
Item 2
Note 1
So I have note pages, which are children of item pages, which are within /items/. Each note has a 'created' datetime field on it. I also have a 'viewed_by' field which determines if a particular user has viewed that note. What I'm going to do is add the user's id to that field once they've viewed it.
On the webpage that the user sees, I need to display items that have one or more notes that have not been viewed by the current user, most recent first (based on 'created' field). After that, I need to show all other items in date order, most recent first.
Is there a way to sort the items like this using only ProcessWire $pages->get or $pages->find, or would I need to add the items to an array first and then loop through that? I thought I might have to loop through all the items to find ones that have an unread note, add those to an array, then loop through the remaining items and add those to the array.
Thanks!