_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.

$file A suggested template file to use.

Code

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

<?php
function _phptemplate_default($hook, $variables, $file = NULL) {
  if (!empty($file) && file_exists(path_to_theme() . "/$file.tpl.php")) {
    $file = path_to_theme() . "/$file.tpl.php";
  }
  else {
    if (file_exists(path_to_theme() . "/$hook.tpl.php")) {
      $file = path_to_theme() . "/$hook.tpl.php";
    }
    else {
      if (in_array($hook, array('node', 'block', 'box', 'comment'))) {
        $file = "themes/engines/phptemplate/$hook.tpl.php";
      }
      else {
        $variables['hook'] = $hook;
        watchdog('error', t('PHPTemplate was instructed to override the %name theme function, but no valid template file was found.', array('%name' => theme('placeholder', $hook))));
        $file = 'themes/engines/phptemplate/default.tpl.php';
      }
    }
  }

  if (isset($file)) {
    extract($variables, EXTR_SKIP);  // Extract the variables to a local namespace
    ob_start();                      // Start output buffering
    include "./$file";               // Include the file
    $contents = ob_get_contents();   // Get the contents of the buffer
    ob_end_clean();                  // End buffering and discard
    return $contents;                // Return the contents
  }

}
?>
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.