phptemplate.engine

Handles integration of PHP templates with the Drupal theme system.

File

drupal/core/themes/engines/phptemplate/phptemplate.engine
View source
<?php

/**
 * @file
 * Handles integration of PHP templates with the Drupal theme system.
 */

/**
 * Implements hook_init().
 */
function phptemplate_init($template) {
  $file = dirname($template->filename) . '/' . $template->name . '.theme';
  if (file_exists($file)) {
    include_once DRUPAL_ROOT . '/' . $file;
  }
}

/**
 * Implements hook_theme().
 */
function phptemplate_theme($existing, $type, $theme, $path) {
  $templates = drupal_find_theme_functions($existing, array(
    $theme,
  ));
  $templates += drupal_find_theme_templates($existing, '.tpl.php', $path);
  return $templates;
}

/**
 * Implements hook_extension().
 */
function phptemplate_extension() {
  return '.tpl.php';
}

/**
 * Renders a system default template, which is essentially a PHP template.
 *
 * @param $template_file
 *   The filename of the template to render.
 * @param $variables
 *   A keyed array of variables that will appear in the output.
 *
 * @return
 *   The output generated by the template.
 */
function phptemplate_render_template($template_file, $variables) {

  // Extract the variables to a local namespace
  extract($variables, EXTR_SKIP);

  // Start output buffering
  ob_start();

  // Include the template file
  include DRUPAL_ROOT . '/' . $template_file;

  // End buffering and return its contents
  return ob_get_clean();
}

Functions

Namesort descending Description
phptemplate_extension Implements hook_extension().
phptemplate_init Implements hook_init().
phptemplate_render_template Renders a system default template, which is essentially a PHP template.
phptemplate_theme Implements hook_theme().