-
☆ A M B ☆
- 326 Posts
Hi everyone,
I could really use some advice from some of you MODx power users regarding working with a database table through MODx. Here goes:
I’m building a course catalog system for a major university using MODx (when all is said and done, this will be an awesome project for showcasing MODx and I’ll be sure to share it with the community). I need to pull the course information in from another system, but all they can provide is a CSV (worth mentioning: every course has a unique course ID). No problem there -- I’ve already figured out how to get the information into my MODx database (in its own table) using the csv2db module.
My problem is, I now need this data to be managed through MODx by other less technical people. I thought about making a new MODx resource for each course and then using a TV with a @select binding to pull from the table (thinking I could manually set each MODx resource pagetitle as the course ID and then match it that way). The problem is, this won’t be editable -- it would just pull from the DB and mirror what’s already there.
What I think I need to do instead is actually create the new MODx resource at the same time I create the mysql table for the courses via straight PHP/MySQL (or a module) and tie it to the other table with either a TV or a foreign key, but I have no idea how to go about this. Can anyone walk me through the process of adding MODx resources directly to the database, with or without using the API? Or, if I’m going about this all wrong, can anyone show me a better method overall? I should mention that I’m average in PHP/MySQL but can usually figure it out if you give me the basics.
Thanks!
-
MODX Staff
- 2,502 Posts
What I would do is use one doc to as the course viewer and create a snippet to retrieve the data (rather than TVs) and return the retrieved data via placeholders.
As far as managing the data there are several ways that can be done from a building a DB Editor Module to writing another snippet to allow updates to the table data that is only available to manager users. The snippet would check to see if the user was a logged in manager, display the course data and allow changes and saves.
If the data import is going to be a one time thing and there aren’t too many courses you could use the CSV to MODx Addon that can be found in the Extras Section and map the tables to document variables.
I am sure someone more dev’y than I can better explain my two options.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
-
☆ A M B ☆
- 326 Posts
Thanks! Module Maker is exactly what I was looking for. I am experiencing an error getting it to run (Fatal error: Call to undefined method module_maker::module_maker). Any ideas? I don’t want to tangent this thread and will gladly ask in the Module Maker support thread if it’s not something obvious.
-
☆ A M B ☆
- 326 Posts
The good news is, I have the basics of the site working using a combination of loopDbChunk and some template variables on each main section to tie the course to the DB table, using @INHERIT to prevent having to manually add it to sub-pages. When I’m completely finished, I’ll be sure to post a link to the finished site!
This still doesn’t solve my problem of being able to edit the DB table through MODx. Module Maker is exactly what I need to pull it off, but I can’t get it working. Anyone have any other suggestions for this type of module, or know what’s wrong with Module Maker?
Thanks!