[development] Re: Rapid Theme Development

Ken Rickard agentrickard at gmail.com
Thu Dec 15 01:49:50 UTC 2005


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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20051215/3934a083/attachment.htm


More information about the development mailing list