Gossamer Forum
Home : Products : DBMan : Customization :

Question about printer-friendly mod

Quote Reply
Question about printer-friendly mod
I have managed to successfully install and use a printer-friendly mod that I found here by adding a new html_printable subroutine and adding the print command:

## print view of record ##
if ($in{'view_printable'}) {
&html_printable (&array_to_hash(0, @hits));
return;
}
### end print record code ###

into view_success and then:

[ <A HREF="$db_script_link_url&view_records=1&view_printable=1&$db_key=$rec{$db_key}&ww=1">Printable Format</A> ]

into html_record_long...however....when I use the printable format link, it just opens up the printable format in the same window, so I still have my background and all the graphics on the page. What I want it to do is pop open a new window that is totally blank except for the text of my record. Can anyone tell me how to modify this mod to open and print from a new window with nothing but the text? Thanks!
Quote Reply
Re: [floridasun5] Question about printer-friendly mod In reply to
To have the printable view open in a new window just add:

target="_blank" within the link to call the subroutine. For example:

[ <A HREF="$db_script_link_url&view_records=1&view_printable=1&$db_key=$rec{$db_key}&ww=1" target="_blank">Printable Format</A> ]


As far as formatting the page display that is done in the sub html_printable. That is where you define your page formatting and contents for example:

sub html_printable {
#---------------------------------

%rec = &get_record($in{$db_key});

$rec{'Description'} =~ s/\n/<BR>/g;

&html_print_headers;

print qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD><TITLE>$rec{'Title'}</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="cache-control" CONTENT = "no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"></HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#110000" LINK="#CC00FF" VLINK="#00CC33" ALINK="#000000">

<CENTER>$site_logo<P>
<TABLE WIDTH="450" CELLPADDING=0 CELLSPACING=0 BORDER=0>
<TR><TD><$font>ID: $rec{'ID'}</FONT></TD><TD align=right><$font>Date:&nbsp; $rec{'Date'}</font></TD></TR>
<TR><TD colspan=2>&nbsp;</TD></TR>
<TR><TH colspan=2>$rec{'Artist'}</TH></TR>
<TR><TD colspan=2>&nbsp;</TD></TR>
<TR><TD><$font>Song Title:</font></TD><TD><$font>&nbsp;<B>$rec{'Song_Title'}</B></font></TD></TR>|;

print "<TR><TD><$font>Album/CD:</font></TD><TD><$font>$rec{'Album'}&nbsp;</font></TD></TR>" if $rec{'Album'};
print qq|
<TR><TD><$font>Genre:</font></TD><TD><$font>$rec{'Genre'}&nbsp;</font></TD></TR>
<TR><TD colspan=2>&nbsp;</TD></TR>
<TR><TD colspan=2><$font>Lyrics:<P></font></TD></TR>
<TR><TD colspan=2><$font>$rec{'Lyrics'}</font>&nbsp;</TD></TR></TABLE>
<P>
<$font><B>[ Close window to return to record ]</B></font></CENTER><P>
</BODY></HTML>|;
}


Hope this helps, otherwise perhaps you could post your sub html_printable so we can check it out.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Question about printer-friendly mod In reply to
Thanks....I did add in the target="_blank" command and it does open in a new window now, however, the new window still contains my background and all the images. I am trying to get the new window to just be completely white except for the text of the record, so the user does not have to print everything else. I have no formatting in my html_printable sub other than the field information, so I cant figure out why it is picking up the formatting from the view_success sub. Here is my subroutine html_printable:

sub html_printable {
#---------------------------------
my (%rec) = @_;
%rec = &get_record($in{$db_key});

&html_print_headers;
print qq|
<html><head><title>$rec{'Title'}</title></head>
<BODY>
<CENTER><b>Recipes</b><P>
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
</TD>
<TD ALIGN="Left" VALIGN="TOP"><b><font color="blue" size="3">$rec{'Title'}</font></b><p>$rec{'Description'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font><b>Category:</b></FONT></TD>
<TD VALIGN="TOP"><$font>$rec{'Category'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font><b>Servings:</b> </FONT></TD>
<TD VALIGN="TOP"><$font>$rec{'Servings'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font><b>Difficulty:</b> </FONT></TD>
<TD VALIGN="TOP"><$font>$rec{'Difficulty'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font><b>PrepTime:</b></FONT></TD>
<TD VALIGN="TOP"><$font>$rec{'PrepTime'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font><b>CookTime:</b></FONT></TD>
<TD VALIGN="TOP"><$font>$rec{'CookTime'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font><b>Ingredients:</b></FONT></TD>
<TD VALIGN="TOP"><$font>$rec{'Ingredients'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font><b>Method:</b></FONT></TD>
<TD VALIGN="TOP"><$font>$rec{'Method'}</TD></TR>
</TABLE></CENTER></BODY></HTML>|;
}

As you can see, nowhere does it have any body background tags or any images added, but yet the images and background show up in the new printable window. Any ideas?
Quote Reply
Re: [floridasun5] Question about printer-friendly mod In reply to
I think perhaps you should add something to your body tag at least give it a text color.

<BODY TEXT="#000000">

I'm not sure if your using the short/long mod or the original DBMan but check where within html view_success you are adding the code for that sub.

It should be after:

my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

and before:

&html_print_headers;

That's the only thing I can think of that might be causing it to include your headers.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Question about printer-friendly mod In reply to
Ok, that did it! :) Thanks so much! I didnt realize that I had that command in the wrong spot but I moved it up into the header and it worked! Thanks again!
Quote Reply
Re: [floridasun5] Question about printer-friendly mod In reply to
Your welcome :) Glad you got it all working.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/