drupal_discover_template

Definition

drupal_discover_template($paths, $suggestions, $extension = '.tpl.php')
includes/theme.inc, line 677

Description

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.

Code

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

  // Loop through all paths and suggestions in FIFO order.
  $suggestions = array_reverse($suggestions);
  $paths = array_reverse($paths);
  foreach ($suggestions as $suggestion) {
    if (!empty($suggestion)) {
      foreach ($paths as $path) {
        if (file_exists($file = $path .'/'. $suggestion . $extension)) {
          return $file;
        }
      }
    }
  }
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.