Good replies here. Let’s keep this going!
@Bob:
TVs should be attached to resources, not templates
-- yes, but more specifically to a
class of Resources. I was calling them "Resource Types", but the idea is that you’d have a class of resources for "Book" or "Movie" or whatever, and each book or movie would have a defined group of fields. From the few beers I’ve with Jason, I understand that where MODx is heading is at least similar to this where ALL fields will essentially be TVs instead of having the default built-in set. However, I’m not sure if this meant we’d have definite "resource classes" where one class would have one set of fields and another class would have different fields.
@Mark: I think this may go beyond what Shaun was talking about here:
http://modxcms.com/forums/index.php/topic,55323.msg318332.html#msg318332 -- but it’s hard to say with some of the sparse comments. It’s interesting there was no mention of this idea in the roadmap...
@lossendae: yes, I’ve just finished a book on WordPress plugins, and I have to agree that the WordPress manager is easier for the end-users, but oh my god... the API and the architecture is positively insane. This is the MODx forums, so I feel safe saying this, but who-ever architected the WordPress
register_post_type() function needs to be hog-tied... it’s nightmarish. I’m working on a plugin (
http://wordpress.org/extend/plugins/custom-content-type-manager/) that more or less gets WordPress about where MODx Evo was in terms of custom fields (i.e. TVs), but the average WP developer has to do some onerous coding using poorly architected functions in order to pull off "custom post types". I agree with you that the end result is cleaner in the manager (the WP templating leaves Drupal in the dust), but it doesn’t hold a candle to MODx). The way that WordPress and MODx handle the custom fields is about the same: there’s a separate table that contains a row containing the data for each custom field. In WordPress, custom field data is stored in the
wp_meta table, whereas in MODx it’s stored in the
modx_site_tmplvar_templates and
modx_site_tmplvar_contentvalues -- the database pattern is similar (extended data is stored in rows, not in columns), although MODx achieves greater usability by using 2 tables instead of 1. That’s why MODx has a standardized set of custom fields for any given template whereas in WordPress, one post might have no custom fields whereas the next post might have 20 -- WordPress is extremely squirrelly in this regard (that’s part of the reason I wrote the above mentioned plugin).
I think Expression Engine actually does extend the database
columns, which has the desired effect of creating "classes" of Resources with dedicated attributes for each (although it makes for some super-wide tables with ridiculous numbers of columns and a larger database footprint).
So instead of associating TVs with a template, I think they should be associated with a "Resource Type" or a "Resource Class" (whatever you want to call it). Templates should also be associated with a particular resource type (or class). That’s one more layer of abstraction that would solve the problems inherent here. WordPress fails because it has no built-in way of standardizing custom fields for a particular "post type". MODx "fails" because it standardizes the fields in the wrong place -- it sort of standardizes them in the the view layer instead of in the model layer (I hope the MVC purists will excuse me). The MODx solution is way more flexible, but it’s still not quite right in my opinion.