Closed (cannot reproduce)
Project:
Printer, email and PDF versions
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Oct 2010 at 19:04 UTC
Updated:
8 Jun 2012 at 21:03 UTC
The print module does not trigger the node_preprocess functions, so in its current form cannot display the print page according to the layout defined via display suite ("print" build mode). See also #847868: Print Module / Layout. Through trial and error I came up with something that seems to work. I am no coder though, so this might not be a good solution. I modified the print_preprocess_print_node function in print.module:
function print_preprocess_print_node(&$variables, $hook) {
$format = $variables['type'];
$type = $variables['node']->type;
$additions = _content_field_invoke_default('preprocess_node', $variables['node']);
$variables = array_merge($variables, $additions);
template_preprocess_node($variables);
if (function_exists('_nd_preprocess_node')) {
_nd_preprocess_node($variables, $hook);
}
$variables['template_files'][] = "node";
$variables['template_files'][] = "node-$type";
$variables['template_files'][] = "print_node";
$variables['template_files'][] = "print_node_$format";
$variables['template_files'][] = "print_node_$format.node-$type";
}
Does this look ok?
Comments
Comment #1
davemybes commentedNIce idea, but it doesn't seem to work for me. I've flushed caches a bunch of times, tried it with and without the print.tpl.php file, but no go. Is there maybe something else you did? Either in print.module, or another module in the print folder?
Comment #2
nevets commentedThis would probably "just work" if the module used node_view() instead of trying to duplicate it's functionality. While it invokes hook_nodeapi() with the case 'alter' it does not invoke it for 'view'.
Comment #3
g.k commentedsubscribing
Comment #4
liquidcms commentedi just posted this: #1044592: does this work with Print? - which i guess is a duplicate of this.
Comment #5
liquidcms commentedi think the correct way to do what you have done is to add this to template.php (hacking modules is not the "drupal way").
do exact code you have but change function name to [mytheme]_preprocess_print_node
http://screencast.com/t/bvzcO9r2L
this works for me except i can't see why/where the byline is coming from (this is shown via DS in std node views; only in print view)
Comment #6
liquidcms commentedi was able to remove the BY $author | [date] byline by disabling this in the theme global settings - this isn't required when using DS for node displays but seems to be for Print pages... which likely means it is a bit of a bug for Print/DS.
Comment #7
ericaordinary commentedFor this to work I had to add an extra line of code so that Display Suite could take over control of the display:
Comment #8
gooddesignusa commentedwhat exactly does
$variables['node']->render_by_ds = TRUE; //extra linedo because it seemed to work for me regardless. On thing I did notice $print['content']; renders a content div & a taxonomy div. Any way to stop the taxonomy from being rendered?I'm using a Display suite code field that renders the taxonomy I want. Since some terms are used for permissions.
Comment #9
waxb commentedhave you found a solution to stop the taxonomy from being rendered?
Comment #10
nguyentran commentedAre there any solutions to solve this, thanks.
Comment #11
jcnventuraCan I ask you to try with the latest version of the module? I've added some code in July 2011 and corrected a minor bug on it early this month, that should be calling Display suite's preprocess node function.
Comment #12
jcnventuraNo further info in two weeks. Closing the issue.