PLEASE excuse the length of this post; I don’t think it’s possible to ask for ideas on this one without explaining the goals and history of my project.
As some of you may know, I’m working on a fairly complex course catalog system for a university, built entirely on MODx. It’s definitely had its challenges, but the flexibility of MODx has made developing it a breeze (thank goodness for custom snippets and @INHERIT TVs, to name just a few).
Now...onto one of those challenges! One of the trickiest parts of the project is that we need an entire catalog year’s worth of data to be duplicated for new catalog years as easily as using the "Duplicate Resource" function in MODx, while keeping the previous year as-is to serve as an archive. The duplicating part is easy, but the problem is, because MODx relies heavily on the unique IDs assigned to every resource in the system, I had to write a lot of custom snippets that returned an ID based on your level in the site hierarchy and your page title rather than the ID itself, and then use this generated ID as the start ID in other snippets like Ditto and Wayfinder. Otherwise, you’d have to go through and manually change a bunch of snippet settings, links, etc. every time you added a catalog year, which would be a nightmare.
That problem is (mostly) solved, but now for my new issue: while some data, such as old catalog years, needs to be static, there is also a need for some of this archived data (such as a phone number or web site link) to be "live" data, so that it’s always current regardless of which catalog year you’re looking at. I have a system set up that does this using an extra table in the DB, a DB editor module and some predefined TVs, but this system can only be displayed in places where I’ve defined it in the template.
What I want to do now is build more of a free-form live data system that lets my content editors throw in a short line of code to display data from a table in the DB, with as little coding know-how as possible (they will have access to edit the data in this table, so don’t worry about that aspect). I could write a snippet to do this and use snippet parameters to define what fields need to be pulled, like so...
[!livedata? &tablerow=`23` &field=`url`!]
...with "tablerow" being the row in the table they want to use, and "field" being the info they want to pull. This may be the best method and I’m comfortable writing this snippet; however, I’m concerned about the complexity of that syntax. It would be nice if the content editors could write something simpler that avoids using backticks, worrying about caching, etc., like maybe a TV with a clever @SELECT binding, such as this:
Even that is a little complicated, but better. Or maybe, the best option is a plugin that watches for a certain syntax, and then makes the call? I worry a bit about the security of this option.
I guess what I’m looking for are ideas. Has anyone tried anything like this before? Any suggestions or helpful tips? How would you go about it if you were creating this system?
Thanks for reading my novel!!!