From 6966b6c597c88e6792680978ab2ee4f3df8dd857 Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Fri, 14 Oct 2011 17:23:48 +1100 Subject: [PATCH] Issue #342350: Fixed issue where template files not overriden by filename. --- includes/theme.inc | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/includes/theme.inc b/includes/theme.inc index bea87c0..837c52c 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1199,10 +1199,10 @@ function drupal_find_theme_templates($cache, $extension, $path) { if (strpos($file->uri, str_replace($subtheme_paths, '', $file->uri)) !== 0) { continue; } - // Chop off the remaining extensions if there are any. $template already - // has the rightmost extension removed, but there might still be more, - // such as with .tpl.php, which still has .tpl in $template at this point. - if (($pos = strpos($template, '.')) !== FALSE) { + // Chop off the remaining '.tpl' extension. $template already has the + // rightmost extension removed, but there might still be more, such as with + // .tpl.php, which still has .tpl in $template at this point. + if (($pos = strpos($template, '.tpl')) !== FALSE) { $template = substr($template, 0, $pos); } // Transform - in filenames to _ to match function naming scheme @@ -1214,6 +1214,20 @@ function drupal_find_theme_templates($cache, $extension, $path) { 'path' => dirname($file->uri), ); } + + // Match templates by designated template file name instead of restricting + // to templates named after the theme funciton hook alone. + foreach ($cache as $hook => $info) { + if (isset($info['template'])) { + $template_candidates = array($info['template'], str_replace($info['theme path'] . '/', '', $info['template'])); + if (in_array($template, $template_candidates)) { + $implementations[$hook] = array( + 'template' => $template, + 'path' => dirname($file->uri), + ); + } + } + } } // Find templates that implement possible "suggestion" variants of registered -- 1.7.0.1