I am submitting this as a request rather than a bug. May need to be added to Drupal core documentation. I did not find it in the core docs.

My theme name contained a hyphen (dash) which when inserted into the function for template.php, did not work. Below is an example before and after. The insertion of the theme name with a hyphen caused the white screen of death when setting up block

Example of bad function:

function my-theme-name_regions() {
  return array(
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'content' => t('content'),
       'header' => t('header'),
       'footer' => t('footer'),
       'blockbar_container_1' => t('blockbar_container_1'),
       'blockbar_container_2' => t('blockbar_container_2'),
         );
}   

Example of good function:

function mythemename_regions() {
  return array(
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'content' => t('content'),
       'header' => t('header'),
       'footer' => t('footer'),
       'blockbar_container_1' => t('blockbar_container_1'),
       'blockbar_container_2' => t('blockbar_container_2'),
         );
}   

Comments

jrabeemer’s picture

Project: Block Bar » Drupal core
Version: 4.7.x-1.x-dev » 7.x-dev
Component: Documentation » documentation

Maybe, "Theme folder names should not have dashes. In Drupal, function overrides use a prefix based on the theme name. While a folder name like "my-site" will load, this is invalid syntax for PHP functions. Use an underscore character or omit dashes altogether when creating a theme folder."

jax’s picture

I had a somewhat similar issue. My design used a theme name with a dash and apparently dashes are not translated to underscores for the function names. This means that a theme shouldn't use dashes at all. Theme's with dashes should not show up in admin/build/themes and that's also where an error should be output indicating to the user that he has themes with illegal names in the themes folder.

jhodgdon’s picture

Title: Inclusion of dash / hyphen warning in readme.txt for template.php function » theme name should not contain a hyphen - document this
Project: Drupal core » Documentation
Version: 7.x-dev »
Component: documentation » Correction/Clarification
Category: feature » bug

PHP does not allow function names to have - in them, because - is used for subtraction. I don't think we need Drupal to document this in the API code anywhere, but the module developer tutorial does explain this: http://drupal.org/node/206754 in the section about choosing a module name.

I don't really see anywhere a "create a theme from scratch" tutorial, so I don't know where I would add this... but I'm moving to the Documentation issue queue for consideration.

leehunter’s picture

There's a note on this page about choosing theme names. http://drupal.org/node/337173 Perhaps it could be added there.

jhodgdon’s picture

Status: Active » Fixed

Actually, that page already does say:
"The name should start with an alphabetic character and contain no spaces or punctuation. Underscores are allowed but not hyphens. Numbers are allowed as long as a number is not the first character."

So I think this is taken care of.

leehunter’s picture

Duh. Should have read the page more closely. I changed the subhead to highlight that that bit is really about the requirements for naming themes.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.