Hi everybody!
Is it possible to use objects for the configuration of my web subpages?
Let me explain:
My page is an interface for showing and editing a small database. I have several types of items that I manage in the database, interrelated in certain ways. For every item type, I have a table page that lists all the items and an edit page, to edit the data of some item in the table I happen to click on.
At the moment, adding another item type is a pain in the ass, because I need to add the type's specifics in numerous php files, in many variables, in large, unwieldy arrays of many dimensions. It's really a reason why my development speed is on the floor.
Is it possible to objectify that structure? I'm thinking of a class "itemtype", and making a new instance for every type that I need. For every type, that is complex subpage, I'd say e.g.
$cds = new itemtype;
and this new object would represent the CDs subpage, holding config and methods specific to the table page I list the CDs on, and to the related edit page with its many form fields. An example for the type of info the object is meant to hold is the definition of the columns on the CDs table page, and a heading for the table, and the resource IDs of the table page and the edit page, and the fields in the editing form, and so on - just everything I need, specific to CDs.
That way, I could instantly see all the necessary fields (by looking into the itemtype class code), and hopefully store the config date in less-ugly-than-multidimensional-arrays structures, and in one place, side-by-side with the other subpage objects.
The main things I'm not sure about are
1. whether that's at all feasible,
2. where I should put the code that makes the (singleton) itemtype instances,
3. how to make them singleton, and
4. how to keep them alive forever.
Any ideas on my lengthy post will be much appreciated!
Cheers,
René
[ed. note: neo2.0 last edited this post 13 years, 11 months ago.]
PHP illiterate MODx enthusiast
PHP illiterate MODx enthusiast