PHPBuilder - Creating a Printer Version Grab Method Page 4



RSS Twitter
Articles Html

Creating a Printer Version Grab Method - Page 4

by: Jim Fletcher
|
April 1, 2004

Create the template
The default template name for the printable version will be 1.html . You may define a different default template for a domain in the MySQL settings for that member.
The most basic template will use 3 tokens: Page Title is !TITLE!, URL to original page is !URL!, and the printable content is !CONTENT! A more fully-featured template which includes both "Print" and "Close This Window" buttons is included in the download version of this script.
<html><head>
<title>!TITLE!</title>
<base href="!URL!"></head>
<body>!CONTENT!
<br><br>Page printed from: !URL!
</body>
</html>
Beginning the Printer Version script
Create a new file called print.php and start the file with:
<?
A few options need to be set in the beginning.
First are the MySQL server connections.

<?php
//Server Settings
    
$mysv="localhost"#your server name
    
$myun="your MySQL username";
    
$mypw="your MySQL password";
    
$mydb="your MySQL database name";
//Connection
    
$db mysql_connect($mysv$myun$mypw);
    
mysql_select_db($mydb,$db);
?>
Next we tell the script how many days to cache the printable HTML content of a webpage. After this many days the script will go spider the webpage again. If your webpages change frequently, you may wish to make this a lower number.

<?php
$daystocache 
5;
?>
Next we define what hidden comment tags we will use to grab the printable content.

<?php
$GrabStart 
"<!--startclickprintinclude-->";
$GrabEnd "<!--endclickprintinclude-->";
?>
You have the option of excluding certain content that is inside of the printable region. Define the comment tags here.

<?php
$ExcludeStart 
"<!--startclickprintexclude-->";
$ExcludeEnd "<!--endclickprintexclude-->"
?>
This defines what tags we will use to find the webpage title.

<?php
$TitleStart 
"<title>";
$TitleEnd "</title>"
?>

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Jim Fletcher

Comment:



Comment:

(Maximum characters: 1200). You have characters left.