JoshoB Posted February 20, 2023 Share Posted February 20, 2023 I am building a website that serves as a client management system. I have organisations (each a page) and they are parent pages to contacts (i.e. people). Both the organisations and the contacts beneath them have a repeater field, "history_repeater", that is used to store comments in. The repeaters consist of a date/time field ("datetime") and a comment field ("comment"). An organisation page should show the complete history for that organisation, i.e. add the "history_repeater" data from the underlying pages (contacts) to the main "history_repeater" field in the organisation page, and then reverse sort the results by "datetime". I cannot seem to figure out how to do this in a neat way without taking recourse to building an array. I think it should be doable with a simple selector and sort, but how escapes me at present. Does anyone have a solution for this? Thank you so much in advance. Link to comment Share on other sites More sharing options...
Robin S Posted February 20, 2023 Share Posted February 20, 2023 Not exactly the same scenario but an example of combining repeater items from different sources into a PageArray: 1 Link to comment Share on other sites More sharing options...
JoshoB Posted February 20, 2023 Author Share Posted February 20, 2023 Oh, cheers! I think I managed to solve it thanks to that thread. For posterity/future reference, this is what I wrote in the parent template: // Populate history_repeater with history from underlying pages, too foreach($page->children() as $child) { $page->history_repeater->add($child->history_repeater); } $page->history_repeater = $page->history_repeater->find("sort=-datetime"); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now