Hi Everyone
Over the past few weeks I’ve been building a MODx plugin designed to make it easy to implement additional custom database tables directly and elegantly in to the website and the MODx backend. Datafrolic makes it easy to associate data (custom tables) with a specific Resource, in either one-to-many or many-to-many relationship. Its designed to make it easy for the a web layperson to edit the data (CRUDding entries,) as well as equally easy for the developer to set up tables for a resource. To my knowledge nothing similar existing yet, so this should be pretty exciting!
The way it works is based (intially) off of the well known Managermanager plugin. There is one section for config, which is run on the ’OnDocFormRender’ event and which describes tables and assigns them to a specific resource or template. This then creates a tab on the resource page when the resource is edited. For example, I have a page ’Articles’, and a custom table of articles in a One to Many relationship. The configuration code is a simple as this (it becomes a little more complex with a many-to-many relationship):
$articles = new df_table_info('news', '', array('date' => 'Article Date', 'title' => 'Title', 'status' => 'Active?') );
$articles->setPrimaryKey('id');
df_createO2MTab('Articles', 'Article', $articles, $current_doc_id,'','',$news);
Really quick: df_table_info describes a table, the arguments for construction are the table name, foreign keys (any connected tables), and summary fields (fields which will be displayed in the table of data in the tab.)
Finally, I’m posting here to try and get a feel for what you guys think of this. My hope is that it will be extremely useful and fill a much-needed void in MODx capability. This was written for the latest Evolution release, I don’t know what would be involved in Revo compatibility. Its maybe about 80% done with a week or so left, the majority of the work left is in documentation, code cleanup, debugging, and adding a few features here and there. I am of course willing to accept help if anyone wants to spend the time to learn my code - as this is one of my first projects of this size & quality, it would be interesting to get feedback from someone more experienced.
Thanks for reading, Let me know what you think!
--Peter