Let me back up and say that I’ve chosen MODx out of many possible contenders, and have been using it mostly happily for quite some time. It’s a fabulous product, and I even though I am offering some suggestions, I don’t do this with any ill-feeling. Sometimes typed messages appear to convey more negativity than intended, so I apologize if it gave that impression.
I’ve put quite a lot of data into MODx that is quite tightly integrated. I’ve used template variables for this purpose because that’s the easiest way to make the data editable in a multi-user environment where most users don’t know HTML. You could easily argue that I should use a custom data format, and you’d be right. But I’m using template variables for their ease of maintenance by non-technical users.
I’ll give a brief overview of some of my data structure. It’s an academic web site:
- People (name, phone, address, email, bio, photo, etc.)
- Courses (title, description, course number, etc.)
- Course instances (sections of courses, with time, room, days, instructor, etc.)
- Buildings (address, campus,etc.)
- Rooms (building, room number, etc.)
There’s a lot more, but this will illustrate the point. On semester schedule pages, there is a list of all the course instances for a given semester. To display this information, I need to pull data from all of the above tables (plus others). The data are linked by the MODx ids of the various documents that contain the relevant information. The course instance has the id of the instructor(s), the id of the course, the id of the building and room.
There isn’t an easy way to pull all of this information together with publicly available MODx snippets. Ditto can easily get all of the course instances, but then I would still need to get all of the related information, which (if I use only Ditto) would mean running Ditto over and over inside itself essentially, which is very inefficient.
If each of the items (people, courses, course instances, buildings, rooms) had a separate table, I could write a single -- though somewhat complex -- query to get all of the information at once. I could conceivably do the same thing by querying the modx_site_tmplvar_contentvalues table in a similar way.
What I ended up doing was creating a single derivative table that contained all of the relevant information, so that I could query it all at once, without having to do any joins. The table contains the peoples’ names, course info, room info, etc. The "hard work" is done by the plugin when I save the document, rather than when the document is viewed on the web. It does slow down the process of saving the documents a little bit, but I’d rather have the slow-down happen there than on the public web site.
My solution may not be the best one, but it does make queries easier and faster. I know for a fact that the schedule pages are faster now (querying one table) than they were before (querying the TV values multiple times), though I don’t have a side by side comparison because the old version no longer exists.