This is really more of a general PHP/HTML question than it is a Kirby-specific question, but as I’m using it in Kirby there may be Kirby-specific suggestions in the answer.
I have a page showing an agenda for an upcoming one day conference. At the last event, I put the agenda in YAML and listed it out with some styling. For this event, there is an advanced track running concurrent with the primary track.
What we’re trying to do now is display the advanced items next to the primary items, with their time slots matching up. The advanced sessions and standard sessions don’t always start at the same time, either, so I kind of need a table that has rows every 15 minutes and lines those up with the events in my YAML fields.
I’m having a really hard time figuring this out. I have a feeling that if I had a general programatic description of what needs to happen I could figure out how to make it happen in PHP, but I’m just really drawing a big blank. I understand if nobody can (or wants to) help, but I’d appreciate any guidance anybody can give.
What about this idea:
- $timegrid which contains all 15 min start times from lets say 8.00 to 17:00
- $standardEvents with all the standard events
- $advancedEvents with all the advanced events
Iterate through $timegrid and create a new row/cell for every quarter of an hour.
Within this loop, check for every standard event if it has a start time that fits; if so, add it into a cell; then do the same with the advanced events.
You might end up with empty cells for the times that do not have events.
This makes sense. I was a little concerned that there would be a bit of overhead involved with checking the array that many times, though, since this involves checking each array on every table row. But I might be over thinking it.
Yeah, that crossed by mind as well, it probably depends on the number of events that you have to go through each time; you could also filter by time, but that would not make any difference I guess, because the filter function iterates through a collection as well.
groupBy method might be an option as well if your events are available as a collection, not sure though.
I ended up just listing the items and applying classes based on the duration, and then using CSS to adjust the height on the table cells accordingly.