开发者

Drupal pop-up window for printing

I have a Drupal website and I need to create a link to a different version of the same page that opens up in a new window but hides all the side bars, blocks and header and just shows the main content. This is so people can print the main content of the page without all the extra bits.

I know I can add in a link to a print version like <a href="print version of page" target="_blank">print version</a>. But then I want to add a new CSS class to the page which I could use to hide the extra bits. I am not sure how I can add the CSS class to the link/page.

I guess I could also use Javascript but not sure about which method to use for thi开发者_开发知识库s.


Try the Drupal Print module, it provides customization for printing pages in Drupal.


If the Drupal Print module doesn't work for you (for some reason), the standard method for creating a print view utilizing CSS is to include in your primary stylesheet the following:

@media print {
  /* style sheet for print goes here */
}

You would redefine the classes, elements, etc inside that stanza to change or suppress them for printing.

Good luck!


You do not need to create a new print-only page.

Instead, you can just add something like the following to the bottom of your stylesheet and the user will print the page without the extras.

@media print {

body {background-image:none; background-color:#fff;} //turns off bg images
                                                     //sets bg to white 

div#header, div#footer, div#nav {display:none;} //hides elements
                                                //change to match your divs etc.

h1, h2, h3, h4, h5, ul, ol, div, p, a {color:black;} //changes text to black

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜