submitted by Gerald Fischer
as mentioned yesterday on IRC I did some work on generating a more complete manager and templates for a given entity/database table. It's not complete especially in the template area, but I thought I'll send it over so you can have a look.
The accompaning zip contains:
1. a modified 'maintenance.html' that includes an additional option to generate the 'extended' version of mgr & templates (the one i've built). to go in /themes/default/default
2. a modified MaintenanceMgr?.php and a new sub-directory templates. MaintenanceMgr? does the following:
* add the table to host.conf.ini if it doesn't exist
* add the module to module table in database
* generate a manager class for a database table with complete add, insert, edit, update, list and delete methods
* generate stubs for Edit.html and List.html templates
* generate language files with the basic key/value pairs already populated.
The code that is generated is taken from the various files in the templates directory, so it's easy to adapt
how to use it:
1. obviously you have to place the files in their respective diretories :-)
2. create a table in the database. something like this will do for a test:
CREATE TABLE `crud` (
`crud_id` int(8) NOT NULL auto_increment,
`name` varchar(255) character set latin1 collate latin1_german1_ci NOT NULL default '',
`description` text character set latin1 collate latin1_german1_ci NOT NULL,
PRIMARY KEY (`crud_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
3. the maintenance panel and fill in the section Create a module with Module Name: crud, Manager Name: CrudMgr?, tick all options and hit 'Create Module now'
4. copy the generated templates from the crud/templates directory to /www/default/crud and modify them to display something reasonable.
5. Go to the modules panel and start the 'Crud manager', add a record, modify a record, delete it.
i hope all goes well, i did some testing already but that's not completly done.
please have a look if the generated code is reasonable, it's based on the tutorial examples, but as you know i'm pretty new to Seagull. maybe you'll have some ideas how to improve it -that l'll appreciate :-)