Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am successfully using this (fantastic) module - - but would like to have the following functionality:
BTW - - I am using only html print
when a user selects "print", a new page is not displayed (that is there is no "preview" page of the printer-formatted output) but instead simply the browser print dialog.
At the moment, I am successfully creating an output in the desired format but it is a requirement that that the user does not re-direct off-page and we do not want a new window.
I am sure this can be done but I am not sure how.
Thanks to all
n
Comments
Comment #1
jcnventura CreditAttribution: jcnventura commentedHi,
There's no way to create the version in an hidden window with the module at the moment.
However, it should be a simple matter of adding the window.close() javascript after the window.print() call in print.pages.inc:
Can you test it and see if it does what you want?
João
Comment #2
newtonpage CreditAttribution: newtonpage commentedThanks do much for the reply
Yes - - this does work but I surely hate to hack your excellent module.
Here is the behavior with your suggested code:
- - window opens
- - waits for user confirm of print
- - window closes
This works for now but here is what I have done in the node tpl where this link is placed:
This is a little unusual but I need to style the link like so:
[image] [grey text] "print" [orange text] "activity"
This has css rollover and the image is supplied by sprite.
Since the html is stripped (rightly) from the title field, I decided to do this like this - - although I could have wrapped that div and replaced it with jQuery.
In any case, to try to avoid hacking the module, I tried without success to intervene in the onclick but I could not get it to work.
I tried putting in:
onclick = "window.open(this.href); window.print(this.href); window.close(this.href); return false;"
but I still this did not work and since it required that I comment out 'send_to_printer' - - well, this is not OK.
The ideal thing, of course, would be to do this in the popups api but this does not work since the popup hates this - - I suspect that it has to do with the way the I have structured the print_html.node-activity.tpl.php - -
I am at looking an ajax call and using a modal to display the page - - not sure if the print command will work here, though, since it may print the whole page plus the modal.
Are you aware of anyone who has successfully used a modal or the popups api here?
In any case, this works for now and I truly appreciate your response.
I have subscribed and I will try to answer questions where I am able.
n
Comment #3
jcnventura CreditAttribution: jcnventura commentedI am thinking about putting an option to NOT close the window automatically when the setting is to open in a new window and print automatically (I can't see any reason why anyone would want a new window + auto print without wanting to close it after).
Comment #4
jcnventura CreditAttribution: jcnventura commentedI've just committed some code that adds a new setting to close the window when both the new window and send to printer are enabled.
Joao