Commit fd72b861 authored by jcnventura's avatar jcnventura

Stable support for print-specific node template (thanks again to pixelmord).

parent 93201596
......@@ -111,10 +111,6 @@ function print_theme() {
'print_format_link' => array(
'variables' => array(),
),
'print_node' => array(
'render element' => 'elements',
'template' => 'print_node',
),
'print' => array(
'variables' => array('print' => array(), 'type' => PRINT_HTML_FORMAT, 'node' => NULL),
'template' => 'print',
......@@ -125,38 +121,17 @@ function print_theme() {
/**
* Implements hook_preprocess_HOOK().
*/
function print_preprocess_print_node(&$variables) {
static $hooks = NULL;
if (!isset($hooks)) {
drupal_theme_initialize();
$hooks = theme_get_registry();
}
function print_preprocess_node(&$variables) {
if ($variables['elements']['#view_mode'] == 'print') {
$type = $variables['elements']['#node']->type;
$format = $variables['elements']['#print_format'];
$nid = $variables['elements']['#node']->nid;
//Stolen from theme() so that ALL preprocess functions are called
$hook = 'node';
$info = $hooks[$hook];
if (isset($info['preprocess functions']) || isset($info['process functions'])) {
$variables['theme_hook_suggestions'] = array();
foreach (array('preprocess functions', 'process functions') as $phase) {
if (!empty($info[$phase])) {
foreach ($info[$phase] as $processor_function) {
if (function_exists($processor_function)) {
// We don't want a poorly behaved process function changing $hook.
$hook_clone = $hook;
$processor_function($variables, $hook_clone);
}
}
}
}
$variables['theme_hook_suggestions'][] = "node__print";
$variables['theme_hook_suggestions'][] = "node__print__{$format}";
$variables['theme_hook_suggestions'][] = "node__print__{$format}__node__{$type}";
$variables['theme_hook_suggestions'][] = "node__print__{$format}__node__{$nid}";
}
$type = $variables['elements']['#node']->type;
$format = $variables['elements']['#print_format'];
$variables['theme_hook_suggestions'][] = "node";
$variables['theme_hook_suggestions'][] = "print_node";
$variables['theme_hook_suggestions'][] = "print_node_{$format}";
$variables['theme_hook_suggestions'][] = "print_node_{$format}.node__{$type}";
}
/**
......@@ -193,7 +168,6 @@ function print_preprocess_print(&$variables) {
$type = (isset($variables['node']->type)) ? $variables['node']->type : '';
$nid = (isset($variables['node']->nid)) ? $variables['node']->nid : '';
// $variables['theme_hook_suggestions'][] = "print";
$variables['theme_hook_suggestions'][] = "print__node__{$type}";
$variables['theme_hook_suggestions'][] = "print__node__{$type}__{$nid}";
$variables['theme_hook_suggestions'][] = "print__{$format}";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment