Commit 23a45c9b authored by jcnventura's avatar jcnventura

Fix #869014: Support content type template suggestions

parent 6d218943
......@@ -112,8 +112,9 @@ function print_theme() {
'print_node' => array(
'variables' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE, 'type' => PRINT_HTML_FORMAT),
'template' => 'print_node',
'base hook' => 'node',
),
'print_page' => array(
'print' => array(
'variables' => array('print' => array(), 'type' => PRINT_HTML_FORMAT, 'node' => NULL),
'template' => 'print',
),
......@@ -121,20 +122,12 @@ function print_theme() {
}
/**
* Clones the node theme registry for print_node so that it works with existing node templates
*/
function print_theme_registry_alter(&$theme_registry) {
// $theme_registry['print_node']['theme path'] += $theme_registry['node']['theme path'];
// $theme_registry['print_page']['theme path'] += $theme_registry['page']['theme path'];
}
/**
* Renders the content of the node using the theme api
* Implements hook_preprocess_HOOK().
*/
function print_preprocess_print_node(&$variables) {
$format = $variables['type'];
$type = $variables['node']->type;
template_preprocess_node($variables);
// template_preprocess_node($variables);
$variables['theme_hook_suggestions'][] = "node";
$variables['theme_hook_suggestions'][] = "node__$type";
$variables['theme_hook_suggestions'][] = "print_node";
......@@ -143,18 +136,18 @@ function print_preprocess_print_node(&$variables) {
}
/**
* Renders the print page, where the node content gets embedded
* Implements hook_preprocess_HOOK().
*/
function print_preprocess_print_page(&$variables) {
function print_preprocess_print(&$variables) {
$format = $variables['type'];
$type = $variables['node']->type;
$variables['show_blocks'] = FALSE;
$variables['show_messages'] = FALSE;
$variables['page']['#show_messages'] = FALSE;
template_preprocess_page($variables);
$variables['theme_hook_suggestions'][] = "print";
$variables['theme_hook_suggestions'][] = "print.node__$type";
$variables['theme_hook_suggestions'][] = "print_$format";
$variables['theme_hook_suggestions'][] = "print_$format.node__$type";
$variables['theme_hook_suggestions'][] = "print__node_{$type}";
$variables['theme_hook_suggestions'][] = "print__{$format}";
$variables['theme_hook_suggestions'][] = "print__{$format}_node_{$type}";
}
/**
......
......@@ -27,7 +27,7 @@ function print_controller_html() {
$print = print_controller($path, $cid, PRINT_HTML_FORMAT);
if ($print !== FALSE) {
$node = $print['node'];
$html = theme('print_page', array('print' => $print, 'type' => PRINT_HTML_FORMAT, 'node' => $node));
$html = theme('print', array('print' => $print, 'type' => PRINT_HTML_FORMAT, 'node' => $node));
print $html;
$nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/' . $path;
......@@ -323,7 +323,6 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
}
if (module_exists('taxonomy')) {
// TODO make this work when taxonomy works again
// $terms = taxonomy_link('taxonomy terms', $node);
// $terms = taxonomy_preview_terms($node);
$print['taxonomy'] = theme('links', array('links' => $terms));
......
......@@ -276,7 +276,7 @@ function print_mail_form_submit($form, &$form_state) {
$params['title'] = $form_state['values']['title'];
$node = $print['node'];
$params['body'] = theme('print_page', array('print' => $print, 'type' => PRINT_MAIL_FORMAT, 'node' => $node));
$params['body'] = theme('print', array('print' => $print, 'type' => PRINT_MAIL_FORMAT, 'node' => $node));
$ok = FALSE;
if (function_exists('job_queue_add') && variable_get('print_mail_job_queue', PRINT_MAIL_JOB_QUEUE_DEFAULT)) {
......
......@@ -68,7 +68,7 @@ function print_pdf_controller() {
$print['sendtoprinter'] = '';
$node = $print['node'];
$html = theme('print_page', array('print' => $print, 'type' => PRINT_PDF_FORMAT, 'node' => $node));
$html = theme('print', array('print' => $print, 'type' => PRINT_PDF_FORMAT, 'node' => $node));
// Convert the a href elements, to make sure no relative links remain
$pattern = '!<(a\s[^>]*?)>!is';
......
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