Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-15 22:08:24

jochelito
New Member
Registered: 2006-10-01
Posts: 3

Changing layout for printing

Hello,

I have a site with the typical header banner, and left-right navigation bars.
So, the question: what is the best way to prepare the page for printing? I’d like to remove the banner and navigation bars, and show only the current article.

The easiest way I can think of is to use another page template, where I can place only the article, or better, use a different, more adapted layout. Is this possible? It seems that the article is tightly linked to the category page, so I can’t define a different one for printing.

The other, slightly longer (and less elegant) way, is to develop a plugin which would exclude contents when a print has been asked. I already know how to do this.

Thanks!

Offline

#2 2006-10-15 23:59:48

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: Changing layout for printing

the easiest way is to use a print stylesheet!

go to PRESENTATION/STYLE and add a stylesheet called “print”

in your <head> add <link rel="stylesheet" href="<txp:css n="print" />" type="text/css" media="print" />

your print stylesheet would have rules like this to remove banner, etc …

<code>#banner {
display:none
}</code>

you can also change font-size for easier reading, for example

when you’ve got your print stylesheet going, you can do a print-preview from your browser to see how it’ll look

Offline

#3 2006-10-16 01:32:37

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Changing layout for printing

Nardo is correct—a print stylesheet is the easiest (and most effective) way. This will help you create a “print” button.

Another option, if you want to combine both print and screen stylesheets into one is to use @media:

@media screen,projection {
	body {
		background: pink;
	}
}
@media print {
	body {
		background: white;
		color: black;
		font: 10pt serif;
	}
}

updated code display

Last edited by jm (2007-05-18 04:02:39)

Offline

#4 2006-10-16 10:23:16

root
Member
From: Manila, Philippines
Registered: 2004-05-31
Posts: 48

Re: Changing layout for printing

A kind of specific how-to article from A List Apart: Going to Print ALA also uses this method for their own site, so you can view their source code to see practical applications.

Of course, in using the CSS method you’ll only get to see the style applied when you view the print preview.

Offline

#5 2006-10-16 22:24:45

adr
New Member
From: US East Coast
Registered: 2006-07-21
Posts: 7
Website

Re: Changing layout for printing

Just a word in favor of separate print-formatted pages &mdash; I save newspaper stories and intelligent weblog articles for later reference. I prefer to use the printable page layouts whenever I can, not because of any difference in presentation but because printable pages invariably strip away nearly all of the irrelevant content like ads, navigation links, and comments from readers. Yes, you can hide those elements using CSS, but those precious stylesheets aren’t going to help when I return to the article two years later. Sometimes a different medium requires a change to the content, not just to the presentation.

Offline

#6 2006-10-17 22:01:49

jochelito
New Member
Registered: 2006-10-01
Posts: 3

Re: Changing layout for printing

Hi, thank you very much for your answers… I’m definetely going with the stlyesheet solution. But then, out of curiosity… It is not possible to show an article in a different page?

Offline

#7 2006-10-21 14:39:56

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: Changing layout for printing

jochelito wrote:

Hi, thank you very much for your answers… I’m definetely going with the stlyesheet solution. But then, out of curiosity… It is not possible to show an article in a different page?

Not through the default functionality I believe. It shouldn’t be too difficult to create a plug-in though. Perhaps something that sniffs an end of a url, like:

http://www.example.com/section-name/article-name/print-version/

And gives you a conditional tag (one that could be used in Forms and Pages):

<txp:abc_if_print>

---

<txp:else />

---

</txp:abc_if_print>

Last edited by mstwntd (2006-10-21 14:40:34)

Offline

#8 2006-10-21 16:00:32

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Changing layout for printing

Actually, if you aren’t using popup comments, you can “abuse” the popup comments form and get another page, plugin free.

Offline

#9 2007-05-17 23:35:17

mwillse
Member
From: brooklyn, ny
Registered: 2006-06-26
Posts: 83
Website

Re: Changing layout for printing

You can build the entire css link with the txp tag instead writing out the html. This:

<txp:css n="print" media="print" format="link" />

Is the same as:

<link rel="stylesheet" href="<txp:css n="print" />" type="text/css" media="print" />

Offline

Board footer

Powered by FluxBB