I was having an issue whereby blocks added to the [content] region weren't being displayed on the print friendly pages, despite being a part of the actual page content.
Perhaps this could be an option in the print-friendly administration.
To accomplish the above I've modified the [print.pages.inc] file as follows:
Line 227, add below:
$print["content"] = $node->body; // original code
$print["content"] .= theme('blocks', 'content'); // additional code
Additional [content] region blocks are now visible on the print friendly pages.
Editing pages.inc.php direclty is not an elegant solution, does anyone have a more graceful solution?
Cheers,
David
Comments
Comment #1
jcnventuraHello,
Sorry, but blocks (even if they are of 'content' type) are - by design - excluded from the printer-friendly page. If you want to include them, you should place the above code in your print.tpl.php file.
João
Comment #2
Wutimer commentedMuch more elegant and works like a charm.
Thank you very much for taking the time to respond João!
Cheers, David.
Comment #3
cbrompton commentedI have tried this process in 5.x 3.5. and it doesn't seem to work.
is there something else I must do to the template?
Comment #4
dougpetch commentedAnd I can't get this hack to work in 5.x-4.0 -- any suggestions would be welcomed
Comment #5
dougpetch commentedOK - I've got it working after getting some help from Joao and doing a little digging in my template.php file. Here's what I did:
1. Looked in my template.php file for the correct name of the region containing the block I wanted to print.
2. Entered the following line in the print.tpl.php file
print theme('blocks', 'content_bottom1');NOTE: 'content_bottom1' is the name of the region used in my template.php file. Yours will likely be different. Also note that you can change where the block prints by changing where you input that line in the print.tpl.php file. For my purposes I placed it directly under the following line:print $print['content']That's all it took. The block's printing exactly as expected.
Comment #6
okaalto commentedIf one has configured page specific visibility settings for a block, I found that it was also needed to add the print path to the page, in order to make the block visible in printer-friendly version, too. E.g. I had certain content area block configured visible for path node/XX only, I had to add path print/XX .
Comment #7
okaalto commentedThere's also another solution. Instead of editing the print.tpl.php and adding blocks using theme function, it is possible to add blocks straight to node content when using PHP-input mode. Not a perfect solution for every case, but offers an option when editing print.tpl.php is not preferred.
See e.g. http://drupal.org/node/161443
Comment #8
halver commentedcould you clarify this a little, for those of us not very proficient coders?
Thanks
This was meant to be a reply to the comment about adding the path if blocks were configured to print only on certain nodes. Sorry.
Comment #9
anandmahadevan commentedThanks dougpetch. You saved my time a lot. Actually i was spent lot my valuable time on printing block in my website. Finally I got the solution from this forum.
Thanks a lot guys!!!
Cheers
Anand Mahadevan
Comment #10
drasgardian commentedfor anyone looking to do this in drupal 7, the code snippet will look like this:
Comment #11
ben_m commentedThanks @drasgardian for the d7 snippet
Comment #12
bcmaloney commentedThis no longer works in d7 after the most recent update (alpha2.) The problem seems to be in the if condition on line 78 in print.pages.inc.
Comment #13
jcnventuraIf the fault is anywhere, it should be in the drupal_theme_initialize() calls in print.module.. However, those are there for a reason...
Comment #14
Drupalnator commentedHey!! The following code worked for me for Drupal 6.
Thanks!!
Comment #15
GinaF commentedWould anyone be able to tell me how to get a designated block to print in Drupal 7? (I'm using 7.x-1.0-beta1 version of Print).
Thanks
Comment #16
sokrplare commentedIn Drupal 7, comment #10 is working great for me...except I needed to have the module(s) that have blocks in that region invoked in time to include their scripts in
<head>. I've created #1650870: Expose hook/config setting to properly include content from other modules in $print['content'] to hopefully brainstorm a solution that doesn't require a hack to the print module.