Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-09-12 19:02:30
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
link to print an article
I want to add a link to the top of each article to be able to print, but I’m not real sure how to do it. I know I need to make a separate stylesheet for print, but I’m not real sure how to call that stylesheet with a link in the actualy page template? Can someone assist?
Offline
Re: link to print an article
For a print stylesheet, use something like this:
<code>
<link rel=“stylesheet” href=”<txp:css />” type=“text/css” media=“screen” />
<link rel=“stylesheet” href=”/css/print.css” type=“text/css” media=“print” />
</code><br/>
~Nick
Offline
#3 2006-09-12 19:41:48
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: link to print an article
Doing it via a print stylesheet – in the head of your page:
<txp:if_individual_article><link rel="stylesheet" type="text/css" media="print" href="print.css" /></txp:if_individual_article>
(Edit: Nick beat me to it…)
If you’re talking about having it be a print friendly page, where you can tell exactly what it’ll look like when you print, you’d need either a plugin or do some magic with chs_if_urlvar.
Last edited by Mary (2006-09-12 19:42:13)
Offline
#4 2006-09-12 20:24:40
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: link to print an article
Mary:
I added this: <txp:if_individual_article><link rel="stylesheet" type="text/css" media="print" href="print.css" /></txp:if_individual_article> into my page but nothing shows up. How do I add text like “Print this article”?
Offline
#5 2006-09-13 01:08:37
- mstwntd
- Member

- From: Melbourne, Australia
- Registered: 2004-12-25
- Posts: 52
Re: link to print an article
Deron, it sounds like you don’t have a lot of experience with printable web documents. Creating separate ‘printer friendly’ pages is so 1996 and, unless you have your screen articles split over multiple pages, completely unnecessary.
What you should ideally do, as suggested above, is create a stylesheet for Print. If you want to make it more ‘paper friendly’, then, rather than over-writing your screen styles, do a whole new layout, removing unnecessary blocks of content (like the menu) with display: none;
<link rel="stylesheet" type="text/css" media="screen, projection" href="screen.css" />
<style type="text/css" media="print">
body {
color: #000;
font: 10pt/1.5 Helvetica, Arial, sans-serif;
}
h1 {
font-size: 20pt;
}
#header, #menu, #nav {
display: none;
}
</style>
There is a way to create a link which will open the Print dialogue box with JavaScript (click), but think twice before adding it. Is your target audience unable to go to File/Print? Are usability ‘features’ necessary when the application already provides simple enough controls (not to mention controls consistent with most other applications that allow printing).
You may also find this article helpful.
Last edited by mstwntd (2006-09-13 01:09:27)
Offline
Re: link to print an article
See this. Just change <?php to <txp:php>.
Don’t forget you can just use media types in your standard CSS:
<link href="site.css" media="all" rel="stylesheet" type="text/css" />
site.css contents
<pre>
media screen,projection {
/*-------------Projection is for Opera in full screen mode
//normal web styles
*/
}
media print {
body {
margin: 2%;
background: white;
color: black;
font: 10pt georgia,serif;
}
/*——————-Hide useless (in print) stuff*/
#access,#menu,form {
display: none;
}
}
</pre>
You could also import the print stylesheet in your main css file using a media type:
<pre>
@import url(print.css) print;
</pre>
Last edited by deldindesign (2006-09-13 02:21:45)
Offline
#7 2006-09-13 03:29:05
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: link to print an article
Egor: You’re right…I don’t. Never thought about it before. :-) Honestly I don’t have a good reason why I want this feature either. Seems I see the ability to print an article with most blog type sites so I thought I’d follow suit. Seems after reading your post I’ll reconsider my postion and work on creating a stylesheet for print.
Thanks everyone for your input and code examples, I’ll have a look at all of them!
Offline
Pages: 1