function _print_get_template in Printer, email and PDF versions 5.4
Same name and namespace in other branches
- 5.3 print.pages.inc \_print_get_template()
Choose most appropriate template
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.
Parameters
format: format of the PF page being rendered (html, pdf, etc.)
$type: name of the node type being rendered in a PF page
Return value
filename of the most suitable template
3 calls to _print_get_template()
- print_controller_html in ./
print.pages.inc - Generate an HTML version of the printer-friendly page
- print_mail_form_submit in print_mail/
print_mail.inc - Process the send by-email form submission.
- print_pdf_controller in print_pdf/
print_pdf.pages.inc - Generate a PDF version of the printer-friendly page
File
- ./
print.pages.inc, line 466
Code
function _print_get_template($format = NULL, $type = NULL) {
$filenames = array();
// First try to find a template defined both for the format and then the type
if (!empty($format) && !empty($type)) {
$filenames[] = "print_{$format}.node-{$type}.tpl.php";
}
// Then only for the format
if (!empty($format)) {
$filenames[] = "print_{$format}.tpl.php";
}
// If the node type is known, then try to find that type's template file
if (!empty($type)) {
$filenames[] = "print.node-{$type}.tpl.php";
$filenames[] = "print.{$type}.tpl.php";
}
// Finally search for a generic template file
$filenames[] = 'print.tpl.php';
foreach ($filenames as $value) {
// First in the theme directory
$file = drupal_get_path('theme', $GLOBALS['theme_key']) . '/' . $value;
if (file_exists($file)) {
return $file;
}
// Then in the module directory
$file = drupal_get_path('module', 'print') . '/' . $value;
if (file_exists($file)) {
return $file;
}
}
}