WillMaster Possibillites Logo EzineSeek Award
Customizing and Using Master PFP
by
Mari Bontrager

Permission is granted to reprint this article in its entirety, provided no reprints are sent in conjunction with unsolicited bulk email, provided no fee or other value is exchanged, provided no changes are made to the article, and provided the author's name, signature lines, and copyright line are printed with the article; except you may change the article's title.

We receive many requests for information about how to modify Master PFP to include special logos, instructions, print buttons, "this content provided by ..." statements, and so forth — things not found on the original web page being converted into printer friendly format.

This article has precise instructions.

We'll also provide several tips on ways to use Master PFP. Some you might not have thought of.

If you're a bit jittery when contemplating working with Perl scripts, this is a good time to gain confidence. You see, it really doesn't matter a whole lot with this script if you miss a comma or introduce a typo. You can always download a fresh copy and try again.

Follow the instructions and you'll smile.

This article refers to version 1.7. Grab your copy at http://willmaster.com/a/14/pl.pl?mpfp

It's a free download.

When modifying Perl programs (any computer programs, actually), be conscious of the fact that a change in one place could effect the program in other places.

When you must change the value of a variable, which is what we'll do today, try to do it where the original code also uses the variable. That way, you have a better understanding of what value you are changing. Doing it in other parts of the code is running the risk that the variable will contain unexpected information.

Adding Content To the Top Of the Page

Master PFP already generates a link back to the original page if you give it that instruction in your web page link. Although the link back is optional, the variable itself still exists in the program. The variable's name is $topURL and that's the one we'll modify.

The place where $topURL is assigned it's value (when applicable) is at line 187. The line begins with

$topURL = "<a href=\"$In{top}\">Click here to 

Immediately below that line, we'll insert the custom content. You can instruct Master PFP to insert your content above or below the link back line.

For above the link back line —

$topURL .= <<THISPART;
(your content goes here)
THISPART

For below the link back line —

$topURL = <<THISPART;
(your content goes here)
$topURL THISPART

An explanation is in order:

The above method of quoting the content to be assigned to the variable $topURL is called a "'here'" document". The format is two left angle brackets, then any string of characters, and then a semi-colon. In the above examples, we used THISPART, for the string of characters. Everything following the semi-colon to the point where the same string of characters is found on a line by itself (THISPART in our example) will be quoted.

If you include a "@" character in the quoted material, you'll need to escape @ with a back slash. Example: name\@domain.com

The value of variables beginning with a "$" sign will be inserted into the quoted content — unless you escape $ with a backslash.

To continue: If you insert a "Print this page" button, the code might look something like this:

$topURL = <<THISPART;
<form>
<input type="button"
 value="Print this page"
 onClick="print()">
</form>
$topURL
THISPART

Or, for a "Print this page" link, something like this:

$topURL = <<THISPART;
<a href="javascript:print()">Print this page</a>
<br><br>
$topURL
THISPART

Adding Content To the Bottom Of the Page

To add content to the bottom of the page, we'll change the bottom link back variable $bottomURL found at line 188. The line begins with

$bottomURL = "<p><a href=\"$In{bottom}\">Click here to 

Immediately below that line, we'll insert the custom content. As earlier, you can instruct Master PFP to insert your content above or below the bottom link back line.

For above the bottom link back line —

$bottomURL = <<THISPART;
(your content goes here)
$bottomURL
THISPART

For below the bottom link back line —

$bottomURL .= <<THISPART;
(your content goes here)
THISPART

The following example adds a "this content provided by ..." statement, with logo, immediately below the bottom link back line:

$bottomURL .= <<THISPART;
<div align="center">
<a href="http://BontragerConnection.com">
<b>This content provided by</b><br>
<img height="88" width="200" border="0"
src="http://BontragerConnection.com/images/wmb_boncon.jpg">
</a>
</div>
THISPART

Now, a Few Tips

Here are the tips promised at the beginning of this article:

Master PFP Tip #1

When you put a link to Master PFP on your web page, the web page that is converted into printer friendly format can be a different page entirely. You could even have a list of links, each link for a different printer friendly page.

When you create the link to Master PFP, simply substitute the current page's URL with the URL of the page to be converted.

Master PFP Tip #2

To put the printer friendly version into a separate window, add target="_blank" to the <a... link tag on the original page. Example:

<a target="_blank"
 href="/cgi-bin/MasterPFP.cgi?doc=thispage.html">
Click here for printer friendly page
</a>

Master PFP Tip #3

Normally, the parts of a page to be displayed in the printer friendly version are specified with

<!-- BEGIN_PRINTER_FRIENDLY_COPY -->
<!-- END_PRINTER_FRIENDLY_COPY -->

tag sets. The method allows you to be selective.

The tags don't actually have to begin with <!— or end with —>, so you can present things on the printer friendly page that do not appear on the original page. Do it like this.

<!-- BEGIN_PRINTER_FRIENDLY_COPY
<p>
This part will not show on the original page because it is
within an HTML comment tag. However, upon formatting the
printer friendly version, the <!-- and the --> will be
removed along with the "...PRINTER_FRIENDLY..." tags.
Therefore, this paragraph will show up in the printer
friendly version.
</p>
END_PRINTER_FRIENDLY_COPY -->

(The above tip #3 works only with the latest versions of Master PFP, version 1.7+).

Now you know how to customize Master PFP. And you know several ways to use it that can make you stand out like a pro.

By: Will Bontrager

Copyright 2002 Bontrager Connection, LLC
http://willmaster.com/possibilities/
subscribe-possibilities@willmaster.com