Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Printer Friendly Version


cfisupply

Recommended Posts

Hi, I have been trying to find a Printer Friendly Version add on so that the category and product detail pages can be printed off. I have seen and am currently using, outside of OsCommerce, a nice PHP script that does a great job at processing the printer friendly request. But I am having problems adding this into OsCommerce. I need to add two html comments into the page to tell the script what to print. I finally got it to work by editing index.php. But when the Printer friendly page comes up, it has a copy of the home index page not what supposed to be printed.

 

Anyone have any ideas on how to get the script to work correctly. Unfortunately I am fairly new to PHP.

Any Help would be gratly appreciated.

Link to comment
Share on other sites

  • 2 weeks later...

Here is the printer script that I am using. All Credit goes to the origional creator. I only added a couple of function links at the bottom.

 

<?
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modifieed: ". gmdate("D, d M Y H:i:s"). " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: post-check=0,pre-check=0");
header("Cache-Control: max-age=0");
header("Pragma: no-cache");
/*
|| Takes the referrer document, only prints the content
|| works only with documents on the same server. good enough :-)
|| Vattekkat Satheesh Babu ([email protected]).
||
|| I put an HTML comment called "document_starts_here" before
|| content starts and another one "document_ends_here" after
|| the content. If you have been following some standard like
|| that, it could be useful.
|| 
|| Installation instructions
|| 1. Copy paste the code here to your favourite editor, and save it as some php3 file
|| 2. The file name doesn't matter. I call it printit.php3 
|| 3. From your other web pages make a link to printit.php3
|| 4. Test it out by clicking on the links in those pages
||
*/
if ($HTTP_REFERER)
$myURL = $HTTP_REFERER;
else
$myURL = "<!-- YOUR URL HERE -->";

// here is the starting comment for your content
$START_CONT="<!-- document_starts_here -->";
// here is the ending comment for your content
$END_CONT = "<!-- document_ends_here -->";

$parsed_url = parse_url($myURL);
$myServer = $parsed_url['host'];
$document = $parsed_url['path'];
if($document[strlen($document)-1]=='/') $document = "$document/index.html";
$base_url = dirname($document);

$fp=fsockopen($myServer,80,&$errno,&$errstr,30);

// if you've name based virtual hosting
$request = "GET $document HTTP/1.1\r\n"; 
$request .= "Host: $myServer\r\n\r\n";
/* if you've normal old type servers, 
comment out the previous two lines and
use the next line instead
*/
//$request = "GET $document HTTP/1.0\r\n\r\n";


if(!$fp) {
 echo "$errstr ($errno)<br>\n";
} else {
 fputs($fp,$request); 
 $content=0;
 $in_title=0;
?>
<HTML>
<HEAD>
<BASE HREF="<? echo "http://$myServer$base_url/"; ?>">
<STYLE TYPE="TEXT/CSS">
<!--
body,p {
background: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif; 
font-size: 10pt;
margin-left: 5px; 
margin-top: 5px;
margin-right: 5px; 
margin-bottom: 5px;
color: #000000;
text-align: justify;
 }

TH.headerrow {
background-color: #CDC8B1;
font-family: verdana,courier;
font-size: 10pt;
color: black;
}
TD.datarow {
font-family: verdana,courier;
font-size: 10pt;
color: black;
}
//-->
</STYLE>
<?
 while(!feof($fp)) {
$line=fgets($fp,4096);  
// this is the stupid part - get the title
// python makes this so easy :-)
if(eregi("<title>",$line)){ $in_title=1; }
if ($in_title==1) $title.=$line;
if(eregi("</title>",$line)){
	$in_title=0;
	if(!eregi("<title>",$line))
		$title.=$line;
}
if(ereg($START_CONT,$line)) {
	$title = eregi_replace("</title>","",eregi_replace("<title>","",$title));
	echo "<TITLE>$title</TITLE>\n</HEAD>\n<BODY>\n";
	$content=1;
}
if(ereg($END_CONT,$line)) $content=0;
if($content==1)echo $line;
}
fclose($fp);
?>
<HR>
<CENTER>
<SMALL>Copyright © <U><!-- YOUR COMPANY / ORGANIZATION NAME HERE --></U>. All rights reserved.</SMALL><BR>
<?echo "<A HREF=\"$myURL\"><SMALL><I>$myURL</I></SMALL></A>\n";?><br />
<a href="java script:history.go(-1)">Back</a>     <a href="java script:window.print()">Click to Print This Page</a>

</CENTER>
</BODY>
</HTML>
<?
}
?>

What I need is to correctly place the two comment tags:

<!-- document_starts_here --> And <!-- document_ends_here -->

to indicate what I want the script to print. Any Ideas???

Link to comment
Share on other sites

  • 11 months later...

I am using this contrib for product printer friendly page

 

http://www.oscommerce.com/community/contri...ns,4174/page,56

 

I see that people searching for a product may come at my printer friendly page (product_print.php)

 

The problem is that by there they cannot access my page , they can either print the page or close the window and leave the site

 

How can i make the print page link to the product_info page for the specific product ????

 

(or should i make the page not indexed by search engines)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...