I’m trying to build a rocket ship, so to say, and I am not exactly an Engineer. This is a metaphor, somewhat, to explain that I have had to teach myself a lot of stuff with Concrete CMS, to achieve what I want. And to preface that there’s plenty I do not know.
Now, I will try to describe what I’m trying to do here, but I also want you, the reader, to keep in mind that I may be missing something obvious to you, just because I “am not an Engineer”, so to say.
I am trying to build a custom template for an Express List Block, but the issue is more about trying to write code that “scales well”, but not to the ABSOLUTE MAXXXXX. Just… trying to do some well-thought-out advanced planning.
I have an Express Object “Event Schedules”, and the Entries in it have upwards of 8 different associations to consider (may even be more in the future?).
Each Entry is generally expected to only have one association relevant, and only select one associated Express Entry that is in another Express Object.
The Express List Block customisation I’m trying to do is one big “Schedules” block, where it shows all the different schedules, grouped together, based on what the association is. But also checking if the schedule is relevant to “this event” (and I think I already know how to make that determination).
The problem that I am grappling with is that it is HIGHLY PROBABLE that as the loop iterates through the Express Entries for the Schedules Express Object, that the order will be chaotic, and not in any way already grouped based on “which” Association. This gives me a problem about grouping the results together on the page. From what I can tell this is because PHP generates HTML (when it does) in-order, and I’m not really seeing a way to add HTML “higher” on the page, once that part of the page is already “generated”.
I want to run the first loop only once, as a goal, for scaling and performance issues. As over time the Express Entry count for this Object is expected to grow more and more over time, and I want to minimise that impacting performance on page generation. So instead of running the loop that churns through the Express Entries for EACH of the associations, I would prefer to do it once, and process the whole list… once… then do useful things with it.
My current working “theory” is to iterate through the Express Entries once, and when I get a “hit” for each of the Associations, I stuff that “hit” into an Array for that Association, and I guess I have one new array for each Association. And THEN after that loop I run another loop for each of those arrays to then pull that data out and render the sections, grouped together, for each “Association” so to say. So that the visual presentation makes sense to humans.
The part that I am unsure of, because “I am not an Engineer” is that… when I stuff the “Entry” result into a new Array… does the full “fidelity” become retained? In that, when I refer to that value in the Array, are all the Express-y-things retained? Can I ->getAssociatedThinggy->getAssociatedThinggyAttribute etc… on each of the things in the new Arrays? Or is that fidelity lost?
I’m open to different methods here, but I also REALLY need to know if this “kills the frog” so to say, by “copying” the result into a new array. Or… maybe it… “just works”? (~.^~MaGiC~.^~)
Thanks for your time and whatever insight can be shared on this matter!