I still say this: If your node.tpl.php contains field_get_items or equivalent, you are doing it wrong, on a very fundamental level. If the formatters provide too much HTML, write your own, write a proper field.tpl.php etc.
Re:Drupal's Golden Handcuffs
by Falkon1313 on Thursday October 04, 2012 @12:56AM
(#4610949)
So in order to "print $person->first_name;", you must first create formatters, display modes, and templates? Point goes to the one who's saying that it's overly complicated. Drupal makes it easy to do difficult things, but infuriatingly difficult to do simple things.
Regarding the use of field_get_items, check the documentation on the return value: "An array of field items keyed by delta if available, FALSE otherwise." Per my requirement of getting a single, OPTIONAL field value, field_get_items might return false, which means we are still looking at something like this overly verbose code:
($first_name = field_get_items('node', $person, 'first_name')) ? array_shift($first_name) : '';
Lastly, "you want a formatter, a whole display mode, etc. You very rarely need that level of plumbing". One of the requirements for this project was that each page represented by a person node would have a very specific layout. This meant that I couldn't rely on Drupal's default layout (even with formatters there was too much baked-in HTML that was unacceptable), and had to create a node--person.tpl.php file, i.e. a custom template.