A user has requested my module (userreview) operate better with the print module.
http://drupal.org/node/60080
Specifically, the user review form (normally collapsed in a fieldset) shows up, expanded, on the print page.

The broader issue is that other modules should be able to know when a request is coming from the print module, so that these other modules can choose to not display content which is inappropriate for the print page.

This patch permits other modules to know when a call to their hook_view() or hook_nodeapi($op='view') function is from the print module. The patch just adds this line of code

//alert other modules that we are generating a printer-friendly page, so they can choose to show/hide info
  $node->printing = true;

...just before calling
node_invoke()
or
node_invoke_nodeapi()

I have already committed code to the userreview module which witholds rendering the user review form when
$node->printing
is true.

Comments

sami_k’s picture

+1 for this patch, I can see a number of utilities for this patch. Also please document this the module's docs if applied.

dz-1’s picture

The issue I was having was with nodevote showing the vote selection and display blocks. After applying your patch it works like a champ!

Great module, glad I can use it now! :)

dz-1’s picture

Sorry for jumping the gun. The node I was viewing actually wasn't displaying the nodevote blocks as it was. So I did a bit more work.

I modified nodevote line 326 from:
if ($page) {
to:
if ($page && !$node->printing) {

and I modified line 337 the same way.. now that i modified NodeVote this patch works great, even on nodes which actually have nodevote blocks to hide ;)

sorry for the confusion!

jcnventura’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hello,

Before I integrate your patch, I would like to know whether the changes that I made in the latest 5.x dev release make it irrelevant. Please test the new version and tell me if your module still needs the $node->printing flag.

Thanks,

Joao Ventura

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

After adding a couple of other module specific-disabling features, I see the wisdom of adding this flag.

I am adding it now.

adr_p’s picture

Version: 7.x-1.x-dev » 6.x-1.12
Status: Closed (fixed) » Needs review
StatusFileSize
new1.04 KB

The patch below allows other modules to know if the page is being printed also on non-node pages. It's as simple as calling:

if (print_printing()) {
  // Page printed.
}

to check if the request comes from the print module and:

print_printing(TRUE);

to mark request as printing.

jcnventura’s picture

Status: Needs review » Closed (fixed)

No.. Drupal build modes are the way to fix this properly.

AgaPe’s picture

Version: 6.x-1.12 » 6.x-1.14
StatusFileSize
new981 bytes

This is a #6 patch for 6.x-1.14 version. Oh it looks like its already in the module, at least for node pages.