I am putting together a new website for my trail-running club and one aspect of it is a calendar of events. This calendar stores both club events as well as other races put on by other entities. I have the information (Run name, date, distance, etc.) stored in a structure object, which works well and is appropriate. For now, I have put the club-owned events in this structure object as well.
However, these club-owned events also have their own pages on our site and it would be more elegant to pull the data from those and merge them with the data in the structure field for the non-club-owned events. Here is the code on the calendar.php page
I wish to merge $events and $club_events and then loop through the results. Since one is a structure object and the other a template object, this cannot be done.
I think you better build 2 arrays with the fields you actually need from the pages and the structure, and merge those. Afterwards you could cast that merged array into a structure if you’ld like to stick with Kirby idiosyncrasies.
Thank you @bvdputte. This sounds like a good approach. I’ve now merge the arrays. Can you give me a hint how to convert that merged array to a structure object?
Thank you @bvdputte and @texnixe for your help. For the record, and in case this may benefit others, here is what I ended up with:
Here are the relevant bits of code from the calendar.php template which lists a bunch of running events, some related to our running club (each of which has its own page) and other external events that are stored in a structure field in the calendar.txt page.