You are here

function print_get_template in Printer, email and PDF versions 5.2

Auxiliary function to resolve the most appropriate template trying to find a content specific template in the theme or module dir before falling back on a generic template also in those dirs.

Return value

string with the most suitable template filename

3 calls to print_get_template()
print_generate_book in ./print.module
Outputs a printer-friendly page. Used for book pages
print_generate_node in ./print.module
Outputs a printer-friendly page. Used for content types
print_generate_path in ./print.module
Outputs a printer-friendly page. Used for drupal core pages.

File

./print.module, line 619
Display printer-friendly versions of Drupal pages

Code

function print_get_template($type = NULL) {
  if ($type) {

    // If the node type is known, then try to find that type's template file
    // First in the theme directory
    $filename = drupal_get_path('theme', $GLOBALS['theme_key']) . "/print.{$type}.tpl.php";
    if (file_exists($filename)) {
      return $filename;
    }

    // Then in the module directory
    $filename = drupal_get_path('module', 'print') . "/print.{$type}.tpl.php";
    if (file_exists($filename)) {
      return $filename;
    }
  }

  // Search for a generic template file
  // First in the theme directory
  $filename = drupal_get_path('theme', $GLOBALS['theme_key']) . "/print.tpl.php";
  if (file_exists($filename)) {
    return $filename;
  }

  // Then in the module directory
  // This one must always exist (provided with the module!)
  return drupal_get_path('module', 'print') . "/print.tpl.php";
}