Re: Accessing the 'media' attribute in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2008-12-03 at 08:00 +0100, Maciek Sokolewicz wrote:
> Clancy wrote:
> > Oh? 
> > 
> > Unfortunately I have had great difficulty trying to find out how
> > things really work, as all the books I have seen are recipe books,
> > which tell you how to achieve particular results, but not what is
> > going on behind the scenes.  I had assumed that when you hit the
> > 'print' button the browser sent a new request to the server, with a
> > different set of parameters, but I gather from your reply that the
> > browser issues the new (printer) page without reference to the server.
> > Is this what actually happens?
> > 
> > If so I fear I will have to work out how to achieve the results I want
> > with CSS styles.  It would have been far simpler if I could have done
> > it in php.
> > 
> > Thank you for your help.
> > 
> > On Wed, 3 Dec 2008 14:34:20 +1300, geek.de@xxxxxxxxx ("German Geek")
> > wrote:
> > 
> >> PHP is a server side language...
> >>
> >> On Wed, Dec 3, 2008 at 2:16 PM, Clancy <clancy_1@xxxxxxxxxxxx> wrote:
> >>
> >>> Is it possible to access the 'media' attribute from php, so (for
> >>> example) you can tailor a page for printing?
> >>>
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> 
> Rule #1 on this list: don't top post.
> 
> That is how it works indeed, you request the page, the server runs the 
> php script, collects the output and sends it to the browser. You view 
> the page in the browser, press print, the browser sends the page data to 
> the printer spooler which sends it to the printer. No PHP involved after 
> it was sent from the server back to the browser. You basically have 2 
> options now:
> 1. change the looks trough a different stylesheet (the pretty option)
> 2. add a "print" button/link on your page which, when clicked, will 
> redirect to a new page in "print format". Then use the javascript print 
> function to call up the browser's print dialog.
> 
> As for books, most PHP books aren't recipe books, so you've been looking 
> at the wrong ones :) I can recommend O'Reilly's books, they're pretty 
> good. Especially Programming PHP [1]. But that's just my general liking 
> of those books ;)
> 
> - Tul
> 
> [1] http://oreilly.com/catalog/9780596006815/
> 
Go with what Yeti said. The browser will automatically pick the right
stylesheet when the user presses the print button or you issue a
window.print() from Javascript. Whatever you do, don't have a separate
page for "print view". This is one of those things that some bright
spark thought to do on a site at work, and the site in question was
already a couple hundred HTML pages, so he effectively doubled that
figure. It makes your work harder in the long run if you need to update
it at any time, and with the media="print" attribute set for the extra
stylesheet, it's automatically selected anyways.

On an aside, Opera has a neat option that lets you select from all the
stylesheets a page has available, which will make it easier when you're
developing the stylesheet rather than having to keep clicking print
preview in your browser!


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux