Closed (fixed)
Project:
Documentation
Component:
Correction/Clarification
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2006 at 13:10 UTC
Updated:
30 Mar 2010 at 01:00 UTC
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
Comment #1
jrabeemer commentedMaybe, "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."
Comment #2
jax commentedI 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.
Comment #3
jhodgdonPHP 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.
Comment #4
leehunter commentedThere's a note on this page about choosing theme names. http://drupal.org/node/337173 Perhaps it could be added there.
Comment #5
jhodgdonActually, 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.
Comment #6
leehunter commentedDuh. Should have read the page more closely. I changed the subhead to highlight that that bit is really about the requirements for naming themes.