function drupal_discover_template

6.x theme.inc drupal_discover_template($paths, $suggestions, $extension = '.tpl.php')

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.

1 call to drupal_discover_template()
theme in drupal-6.x/includes/theme.inc
Generates the themed output.

File

drupal-6.x/includes/theme.inc, line 754
The theme system, which controls the output of Drupal.

Code

function drupal_discover_template($paths, $suggestions, $extension = '.tpl.php') {
  global $theme_engine;

  // Remove slashes or null to prevent files from being included from
  // an unexpected location (especially on Windows servers).
  $extension = str_replace(array("/", "\\", "\0"), '', $extension);

  // Loop through all paths and suggestions in FIFO order.
  $suggestions = array_reverse($suggestions);
  $paths = array_reverse($paths);
  foreach ($suggestions as $suggestion) {
    if (!empty($suggestion)) {
      $suggestion = str_replace(array("/", "\\", "\0"), '', $suggestion);
      foreach ($paths as $path) {
        if (file_exists($file = $path . '/' . $suggestion . $extension)) {
          return $file;
        }
      }
    }
  }
}