Re: Rapid Theme Development
Here's a practical example of where theme development runs into trouble from module theme functions: overusing theme functions or using the wrong theme functions. In theme.inc (core) is the function theme_form_element which is roughly this (may be old code): function theme_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) { $output = "<div class=\"form-item\">\n"; $required = $required ? '<span class="form-required">*</span>' : ''; if ($title) { if ($id) { $output .= " <label for=\"$id\">$title:</label>$required<br />\n"; } else { $output .= " <label>$title:</label>$required<br />\n"; } } Now, the <br /> tags _aren't_ the big problem here. The problem is that modules (including core modules like profile.module) call this function for both form input _and_ form output. From a design/theme p.o.v., those are two distinct things and should be treated as such. Is this a _really big deal_ that causes Drupal to break? Probably not. But imagine my surprise when I used PHPTemplate to override this theme function, and all the form elements on my entire site changed instantly (and broke).
Ken Rickard wrote:
The problem is that modules (including core modules like profile.module) call this function for both form input _and_ form output. From a design/theme p.o.v., those are two distinct things and should be treated as such.
I agree, the form API should never be used for output. Unfortunately there isn't a good themeable function in core for label/value data. All of my sematic-HTML-preaching friends recomend a definition list [1] for this. We would need a basic style in drupal.css. I suggest this be making <dt> bold and <dd> unindented to match the visual styling of theme_form_item(). 1. http://www.w3.org/TR/html4/struct/lists.html#h-10.3 -- Neil Drumm http://delocalizedham.com/
Ken Rickard wrote:
In theme.inc (core) is the function theme_form_element which is roughly this (may be old code):
This definitely is one of Drupal's more bizarre idiosyncrasies. It would be nice to see this turn into something more elegant. -Robert
participants (3)
-
Ken Rickard -
Neil Drumm -
Robert Douglass