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

davemybes’s picture

NIce 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?

nevets’s picture

This 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'.

g.k’s picture

subscribing

liquidcms’s picture

i just posted this: #1044592: does this work with Print? - which i guess is a duplicate of this.

liquidcms’s picture

i 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)

liquidcms’s picture

i 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.

ericaordinary’s picture

For this to work I had to add an extra line of code so that Display Suite could take over control of the display:

$type = $variables['node']->type;
$additions = _content_field_invoke_default('preprocess_node', $variables['node']);
$variables = array_merge($variables, $additions);

$variables['node']->render_by_ds = TRUE; //extra line
  
  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";
}
gooddesignusa’s picture

what exactly does $variables['node']->render_by_ds = TRUE; //extra line do 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.

waxb’s picture

have you found a solution to stop the taxonomy from being rendered?

nguyentran’s picture

Are there any solutions to solve this, thanks.

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Can 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.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No further info in two weeks. Closing the issue.