function _phptemplate_default in Drupal 4
Same name and namespace in other branches
- 5 themes/engines/phptemplate/phptemplate.engine \_phptemplate_default()
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.
1 string reference to '_phptemplate_default'
- _phptemplate_callback in themes/
engines/ phptemplate/ phptemplate.engine - Execute a template engine call.
File
- themes/
engines/ phptemplate/ phptemplate.engine, line 313 - Handles integration of templates written in pure php with the Drupal theme system.
Code
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
}
}