diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-29 16:56:13 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-29 16:56:13 +0000 |
commit | 327e1c2919cac4481975e2702d74c18a6e858389 (patch) | |
tree | 624fbb7b876f0b6f899e7afc64399dcbf392c83d /includes/theme.inc | |
parent | ffdfe048580748a9dbcfdfdc3bf8c0b0b7f6bddb (diff) | |
download | brdo-327e1c2919cac4481975e2702d74c18a6e858389.tar.gz brdo-327e1c2919cac4481975e2702d74c18a6e858389.tar.bz2 |
#165343 by merlinofchaos and dvessel: include path history in theme discovery suggestions, so we find subtheme files properly
Diffstat (limited to 'includes/theme.inc')
-rw-r--r-- | includes/theme.inc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index 026ce50ac..9250522e4 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -256,6 +256,14 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { if (!isset($info['arguments']) && isset($cache[$hook])) { $result[$hook]['arguments'] = $cache[$hook]['arguments']; } + // Likewise with theme paths. These are used for template naming suggestions. + // Theme implementations can occur in multiple paths. Suggestions should follow. + if (!isset($info['theme paths']) && isset($cache[$hook])) { + $result[$hook]['theme paths'] = $cache[$hook]['theme paths']; + } + // Check for sub-directories. + $result[$hook]['theme paths'][] = isset($info['path']) ? $info['path'] : $path; + // Check for default _preprocess_ functions. Ensure arrayness. if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) { $info['preprocess functions'] = array(); @@ -570,7 +578,7 @@ function theme() { } if ($suggestions) { - $template_file = drupal_discover_template($suggestions, $extension); + $template_file = drupal_discover_template($info['theme paths'], $suggestions, $extension); } if (empty($template_file)) { @@ -587,17 +595,23 @@ function theme() { } /** - * Choose which template file to actually render; these are all - * suggested templates from the theme. + * Choose which template file to actually render. These are all suggested + * templates from themes and modules. Theming implementations can occur on + * multiple levels. All paths are checked to account for this. */ -function drupal_discover_template($suggestions, $extension = '.tpl.php') { +function drupal_discover_template($paths, $suggestions, $extension = '.tpl.php') { global $theme_engine; - // Loop through any suggestions in FIFO order. + // Loop through all paths and suggestions in FIFO order. $suggestions = array_reverse($suggestions); + $paths = array_reverse($paths); foreach ($suggestions as $suggestion) { - if (!empty($suggestion) && file_exists($file = path_to_theme() .'/'. $suggestion . $extension)) { - return $file; + if (!empty($suggestion)) { + foreach ($paths as $path) { + if (file_exists($file = $path .'/'. $suggestion . $extension)) { + return $file; + } + } } } } |