summaryrefslogtreecommitdiff
path: root/modules/block/block.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/block/block.module')
-rw-r--r--modules/block/block.module10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index 2f7e372fe..73eba3311 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -943,7 +943,15 @@ function template_preprocess_block(&$variables) {
$variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->region;
$variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module;
- $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module . '__' . $variables['block']->delta;
+ // Hyphens (-) and underscores (_) play a special role in theme suggestions.
+ // Theme suggestions should only contain underscores, because within
+ // drupal_find_theme_templates(), underscores are converted to hyphens to
+ // match template file names, and then converted back to underscores to match
+ // pre-processing and other function names. So if your theme suggestion
+ // contains a hyphen, it will end up as an underscore after this conversion,
+ // and your function names won't be recognized. So, we need to convert
+ // hyphens to underscores in block deltas for the theme suggestions.
+ $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module . '__' . strtr($variables['block']->delta, '-', '_');
// Create a valid HTML ID and make sure it is unique.
$variables['block_html_id'] = drupal_html_id('block-' . $variables['block']->module . '-' . $variables['block']->delta);