Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2008-04-24 03:17:42

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Link to printer-friendly CSS

In the meanwhile, Gocom (thanks, Go!) helped me at #textpattern on irc.freenode.net and suggested me this code:

		echo (gps('print')) ? 
			'<link rel="stylesheet" href="'.css(array('n' => 'print')).'" media="all" />' : 
			'<link rel="stylesheet" href="'.css(array()).'" media="all" />';

I haven’t tested it yet but I share it here for two reasons: for others who can also need it, and for having an explanation about this one snippet too.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#17 2008-04-24 03:26:55

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Link to printer-friendly CSS

echo ((gps('print')) ? 
	'<link rel="stylesheet" href="'.css(array('n' => 'print')).'" media="all" />'.n : 
	'<link rel="stylesheet" href="'.css(array()).'" media="all" />'.n).
	'<link rel="stylesheet" href="'.css(array('n' => 'print')).'" media="print" />';

That is better, but your right, that code you pasted doesn’t even really work. And yeah, you have misunderstood the meaning of it: It should make the page look printable, same as it would be when it is printed, but in the browser. Also, it’s quite pointless to post this thread as this is way old.

And the code you “why it isn’t just this:” is just because that snippets has zero meaning. Nada. Printable stylesheet in conditionals? That is only for printers media="print". So user must click link and then print? Wow, amazing navigation, nope, it was not the idea of the original snippet as I explained.

Isn’t it nice to view page like it would look in A4? Yeah, it is. And that is what it could do. To access the script, use <a href="?print=print-this-page">Print me</a> or something else.

Last edited by Gocom (2008-04-24 03:29:42)

Offline

#18 2008-04-24 04:26:59

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Link to printer-friendly CSS

Thanks again, Gocom.

It took me some minutes to understand that your writing (condition ? true, do this : false, do this) was one of those ways of writing conditionals.

And, finally, this is the code I was looking for:

<txp:php>
echo ((gps('print')) ? 
	'<link rel="stylesheet" href="<txp:rvm_css n="print" />" media="all" /><!-- true -->'.n : 
	'<link rel="stylesheet" href="<txp:rvm_css n="print" />" media="print" /><!-- false -->');
</txp:php>

Just wanted “print.css” with different media types, because all other stylesheet are linked already above, outside the print conditional.

Also, just to know, could chs_if_urlvar have done the work too, right? If i understand correctly, it is also useful to evalute ?variable=value on URLs.

Last edited by maniqui (2008-04-24 04:27:17)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#19 2008-04-24 04:39:38

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Link to printer-friendly CSS

maniqui wrote:

Also, just to know, could chs_if_urlvar have done the work too, right? If i understand correctly, it is also useful to evalute ?variable=value on URLs.

Yes, it would, and so would rah_if_gps.

Offline

Board footer

Powered by FluxBB