Hello, everyone. I am looking for a simple script to implement on my web site that will let users print my pages (without background colors, more readable, etc.) I am very fluent in scripting languages (ASP, JScript, VBScript, ADO, etc.), so implimentation shouldn't be a problem. Please post a response as this would be a great help to my web site. It would also be intriguiging to know how SitePoint does it themselves (for all you SitePoint Admins out there). Thanks!
Since all of our content resides in a MySQL database, our printable article view is simply a different PHP script that formats the text of our articles appropriately. If you want to discuss this further, however, the conversation would best be moved to the server-side scripting forum.
By looking for a client-side solution I think you'd be making a lot of extra work for yourself...
I think he was referring to Printer-Friendly Versions of pages, and Kevin's right: it's a bit more complex that that.
Quite simply, you want to have a page, say, "print.php" - on the link to view a printable version on your article page (let's say the URL of the article is "article.php?id=1") - you'd create a link within PHP like this:
echo("<a href=\"print.php?id=$id\">View A Printable Version</a>");
So, in this case, going to the article with an ID of "1" would produce a link leading to "print.php?id=1" - from then on, it's simple: you have the print.php page check for the variable "$id" - and if it exists, grab the corresponding record from whatever database you're using.
Hey,
Here's a simple way of doing what you want. On the page you want to print just link to this file. On each page you wan't to be printable just put <!-- body --> and <!-- /body --> around the content. The script then pulls the text and displays the content in anyway you want.
<?php
$lines_array = file("$HTTP_REFERER");
$lines_string = implode('', $lines_array);
eregi("<!-- body -->(.*)<!-- /body -->", $lines_string, $body);
Bookmarks