![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
print this page
I am trying to add a PHP "print this page" script to my dreamweaver template,
that I created myself and it does not want to work once uploaded. The template has one editable area for content. This is the script ( I found on the internet). I am not a developer but I suspect that the fact I am using a template is the problem. <?php /*PHPrint - Save this file as phprint.php Make any Page Printer Friendly! Copyright by MikeNew.Net, Notice must stay intact ************ Legal: MikeNew.Net is not responsible for any damages caused by use of this script. (Not that it will, probably. Never has.) This script will make your pages printer friendly. Optionally, it will strip images as well. */ //Do you want to strip images from the printable output? // If no, change to "no". Otherwise, images are stripped by default. $stripImages = "no"; // That's it! No need to go below here. Upload it and test. $startingpoint = "<!-- startprint -->"; $endingpoint = "<!-- stopprint -->"; $read = fopen($HTTP_REFERER, "r"); $value = ""; while(!feof($read)){ $value .= fread($read, 4096); } fclose($read); $start= strpos($value, "$startingpoint"); $finish= strpos($value, "$endingpoint"); $length= $finish-$start; $value=substr($value, $start, $length); function i_denude($variable) { return(eregi_replace("<img src=[^>]*>", "", $variable)); } function i_denudef($variable) { return(eregi_replace("<font[^>]*>", "", $variable)); } $PHPrint = ("$value"); if ($stripImages == "yes") { $PHPrint = i_denude("$PHPrint"); } $PHPrint = i_denudef("$PHPrint"); $PHPrint = str_replace( "</font>", "", $PHPrint ); echo $PHPrint; // Next line mandatory. Please don't remove. Nobody will see it except SE crawlers, anyway. Thanks! :) echo "<br><a href=\"http://www.mikenew.net/\"><img src=\"http://www.mikenew.net/images/php.gif\" "; echo "alt=\"printer friendly pages script, php\" width=\"20\" height=\"8\" border=\"0\"></a>"; echo "<br/><br/>This page printed from: $HTTP_REFERER"; flush (); ?> |
|
|||
|
Re: print this page
What are you expecting this script to do? What attracted you to it?
-- Murray --- ICQ 71997575 Adobe Community Expert (If you *MUST* email me, don't LAUGH when you do so!) ================== http://www.projectseven.com/go - DW FAQs, Tutorials & Resources http://www.dwfaq.com - DW FAQs, Tutorials & Resources ================== "fatpad" <webforumsuser@macromedia.com> wrote in message news:frt5fl$jnd$1@forums.macromedia.com... >I am trying to add a PHP "print this page" script to my dreamweaver >template, > that I created myself and it does not want to work once uploaded. The > template > has one editable area for content. This is the script ( I found on the > internet). I am not a developer but I suspect that the fact I am using a > template is the problem. > > <?php > > /*PHPrint - Save this file as phprint.php > Make any Page Printer Friendly! > Copyright by MikeNew.Net, Notice must stay intact > ************ > Legal: MikeNew.Net is not responsible for any damages caused > by use of this script. (Not that it will, probably. Never has.) > This script will make your pages printer friendly. > Optionally, it will strip images as well. */ > > //Do you want to strip images from the printable output? > // If no, change to "no". Otherwise, images are stripped by default. > $stripImages = "no"; > // That's it! No need to go below here. Upload it and test. > > $startingpoint = "<!-- startprint -->"; > $endingpoint = "<!-- stopprint -->"; > > $read = fopen($HTTP_REFERER, "r"); > $value = ""; > while(!feof($read)){ > $value .= fread($read, 4096); > } > fclose($read); > $start= strpos($value, "$startingpoint"); > $finish= strpos($value, "$endingpoint"); > $length= $finish-$start; > $value=substr($value, $start, $length); > > function i_denude($variable) > { > return(eregi_replace("<img src=[^>]*>", "", $variable)); > } > > function i_denudef($variable) > { > return(eregi_replace("<font[^>]*>", "", $variable)); > } > > $PHPrint = ("$value"); > > if ($stripImages == "yes") { > $PHPrint = i_denude("$PHPrint"); > } > > $PHPrint = i_denudef("$PHPrint"); > $PHPrint = str_replace( "</font>", "", $PHPrint ); > > echo $PHPrint; > // Next line mandatory. Please don't remove. Nobody will see it except SE > crawlers, anyway. Thanks! :) > echo "<br><a href=\"http://www.mikenew.net/\"><img > src=\"http://www.mikenew.net/images/php.gif\" "; > echo "alt=\"printer friendly pages script, php\" width=\"20\" height=\"8\" > border=\"0\"></a>"; > echo "<br/><br/>This page printed from: $HTTP_REFERER"; > flush (); > ?> > |
|
|||
|
Re: print this page
I hoped that it would allow users of that web site to print each page without
all the design round it, ie. strip all layout images and just print the the content as selected by the script. At the moment the site does not print nicely, the page breaks are all out and so forth...I was hoping I could add a script that can do that, kind of strip the rest of the site (Layout) and just print content. Even if someone could tell me how to set the print page breaks that would be great so i don't have some weird overlap from one page to the other when printing. I hope I am expressing myself correctly here! |
|
|||
|
Re: print this page
|
|
|||
|
Re: print this page
This is an upadated version of the script
<?php /************************************************** ********************** ** PHPrint originally created by MikeNew.Net * Version 1.3 * ** Updated for use with PHP 4.1.xx 9-22-02 ** Updated opening and reading of html page 9-22-02 ** Updated functions to pass values by reference 9-22-02 ** Updated function i_denude() to strip all img tags 9-25-02 ** Addition of Javascript printWin() function 9-22-02 ** Collaborative effort by: lunadesign.org * looneynav.com * thejehm.net * ** Legal: Users of this script are responsible for any damages caused * by use of this script. (Not that it will, probably. Never has.) * This script will make your pages printer friendly. * By default this version will strip images as well. * ** Use: Link the page you would like to print to this page with a * standard html <a href="">Link</a> tag. * ** To leave images intact change line 47 to $stripImages = "no"; * ** This page must be in the same directory as the page for print. * ** Place <!-- startprint --> at the beginning of the content you * would like to print and <!-- stopprint --> at the end. * ** That's all there is to it. ************************************************** ***********************/ ?> <html> <head> <title>Print this Page</title> <script language="Javascript"> function printWindow() { bV = parseInt(navigator.appVersion); if (bV >= 4) window.print(); } </script> </head> <body onLoad="printWindow()"> <?php $stripImages = "yes"; $startingpoint = "<!-- startprint -->"; $endingpoint = "<!-- stopprint -->"; //RETURN THE FILENAME $referer = $_SERVER['HTTP_REFERER']; $file = $referer; $arrfile = explode("/", $file); $intfile = count($arrfile); $file = $arrfile[($intfile-1)]; //DONE $read = fopen($file, "rb"); $value = ""; while(!feof($read)){ $value .= fread($read, filesize($file)); } fclose($read); $start= strpos($value, "$startingpoint"); $finish= strpos($value, "$endingpoint"); $length= $finish-$start; $value=substr($value, $start, $length); function i_denude(&$variable){ //STRIP ALL TAGS THAT START WITH <img... return eregi_replace("<img[^>]*>", "", $variable); } function i_denudef(&$variable){ return(eregi_replace("<font[^>]*>", "", $variable)); } $PHPrint = ("$value"); if ($stripImages == "yes") { $PHPrint = i_denude($PHPrint); } $PHPrint = i_denudef($PHPrint); $PHPrint = str_replace( "</font>", "", $PHPrint ); $PHPrint = stripslashes($PHPrint); echo $PHPrint; echo "\n<br />\n<br />\n<br /> This page was printed from: $referer"; flush (); ?> </body> </html> |
|
|||
|
Re: print this page
Then why not use a Print CSS rather than scripting?
http://www.alistapart.com/articles/goingtoprint/ -- Murray --- ICQ 71997575 Adobe Community Expert (If you *MUST* email me, don't LAUGH when you do so!) ================== http://www.projectseven.com/go - DW FAQs, Tutorials & Resources http://www.dwfaq.com - DW FAQs, Tutorials & Resources ================== "fatpad" <webforumsuser@macromedia.com> wrote in message news:fruf6f$461$1@forums.macromedia.com... >I hoped that it would allow users of that web site to print each page >without > all the design round it, ie. strip all layout images and just print the > the > content as selected by the script. At the moment the site does not print > nicely, the page breaks are all out and so forth...I was hoping I could > add a > script that can do that, kind of strip the rest of the site (Layout) and > just > print content. Even if someone could tell me how to set the print page > breaks > that would be great so i don't have some weird overlap from one page to > the > other when printing. I hope I am expressing myself correctly here! > |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|