_phptemplate_default

Versions
4.7
_phptemplate_default($hook, $variables, $file = NULL)
5
_phptemplate_default($hook, $variables, $suggestions = array(), $extension = '.tpl.php')

Default callback for PHPTemplate.

Load a template file, and pass the variable array to it. If the suggested file is not found, PHPTemplate will attempt to use a $hook.tpl.php file in the template directory, and failing that a $hook.tpl.php in the PHPTemplate directory.

Parameters

$hook The name of the theme function being executed.

$variables A sequential array of variables passed to the theme function.

$suggestions An array of suggested template files to use. This may include a path when the suggested template is contained within a sub-directory of the theme. They are set from _phptemplate_variables() or the theming hook invoking _phptemplate_callback().

Code

themes/engines/phptemplate/phptemplate.engine, line 379

<?php
function _phptemplate_default($hook, $variables, $suggestions = array(), $extension = '.tpl.php') {
  global $theme_engine;

  // Loop through any suggestions in FIFO order.
  $suggestions = array_reverse($suggestions);
  foreach ($suggestions as $suggestion) {
    if (!empty($suggestion) && file_exists(path_to_theme() .'/'. $suggestion . $extension)) {
      $file = path_to_theme() .'/'. $suggestion . $extension;
      break;
    }
  }

  if (!isset($file)) {
    if (file_exists(path_to_theme() ."/$hook$extension")) {
      $file = path_to_theme() ."/$hook$extension";
    }
    else {
      if (in_array($hook, array('node', 'block', 'box', 'comment'))) {
        $file = path_to_engine() .'/'. $hook . $extension;
      }
      else {
        $variables['hook'] = $hook;
        watchdog('error', t('%engine.engine was instructed to override the %name theme function, but no valid template file was found.', array('%engine' => $theme_engine, '%name' => $hook)));
        $file = path_to_engine() .'/default'. $extension;
      }
    }
  }

  if (isset($file)) {
    return call_user_func('_'. $theme_engine .'_render', $file, $variables);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.