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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | print-check_if_printing_page_function-60817-8.patch | 981 bytes | AgaPe |
| #6 | print-printing.patch | 1.04 KB | adr_p |
| print_alert_other_modules.patch | 787 bytes | dado |
Comments
Comment #1
sami_k commented+1 for this patch, I can see a number of utilities for this patch. Also please document this the module's docs if applied.
Comment #2
dz-1 commentedThe 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! :)
Comment #3
dz-1 commentedSorry 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!
Comment #4
jcnventuraHello,
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
Comment #5
jcnventuraAfter adding a couple of other module specific-disabling features, I see the wisdom of adding this flag.
I am adding it now.
Comment #6
adr_p commentedThe patch below allows other modules to know if the page is being printed also on non-node pages. It's as simple as calling:
to check if the request comes from the print module and:
print_printing(TRUE);to mark request as printing.
Comment #7
jcnventuraNo.. Drupal build modes are the way to fix this properly.
Comment #8
AgaPe commentedThis is a #6 patch for 6.x-1.14 version.Oh it looks like its already in the module, at least for node pages.