Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Printer-friendly-mod?

Quote Reply
Printer-friendly-mod?
Hi,

i've searched but didn't find anything like a mod for a "printer-friendly" output of a (detailed) page - does this exist or does anyone got a hint for me?

Thanks!
Chef

Quote Reply
Re: Printer-friendly-mod? In reply to
Couple suggestions:

1) Copy Detailed Pages

a) Copy the "detailed" codes in the Links.pm file.
b) Copy the "detailed" sub in the HTML_Templates.pm file.
c) Copy the "detailed" sub in the nph-build.cgi to create $LINKS{build_print_path} . "/" . $link-
>{'ID'} . $LINKS{build_extension};
. You will have to replace all occurrences of $LINKS{build_detail_url} with $LINKS{build_print_url}.
d) Then add a link in your link.html file like the following:

Code:

<a href="<%build_print_url%>/<%ID%>.<%build_extension%>">Printable Page</a>


NOTE: Be aware that if you use this method, your disk space will multiple. If you are on a dedicated server or have a lot of disk space, then it should not pose a problem. HOWEVER, if you are on a virtual account and you do not have a lot disk space, then the next suggestion may be better for you. ALSO, this will lengthen your build process.

2) Hack info.cgi

Hack the info.cgi code hack for Links 2.0, which is located in the Resource Center to create a dynamic link of printable information.

Regards,

Eliot Lee
Quote Reply
Re: Printer-friendly-mod? In reply to
I would build these pages dynamically rather then building them.

They wouldn't recieve too many hits, and I think that when you compare how much diskspace you would use vs the ammount of CPU it would take - building it dynamically is the best way to go.

It would be a very simple hack to make it PHP :)

Michael Bray
Quote Reply
Re: Printer-friendly-mod? In reply to
Hi Michael,

yes - i could use php - but i've now idea to do this ;)

Basically i'd like to "build" a "printer-friendly-page" only from a static detailed html-page ...

Regards
Chef

Quote Reply
Re: Printer-friendly-mod? In reply to
Ok - But look how simple it would be to do in PHP...

<?php

# Couple of config q's

$dbserver = "localhost";
$dbusername = "";
$dbpassword = "";
$dbname = "Links";

function connect(){
if ($dbpassword == ""){
$link = @mysql_pconnect ($dbserver, $dbusername);
if ($link && mysql_select_db($dbname));
} else {
$link = @mysql_pconnect ($dbserver, $dbusername, $dbpassword);
if ($link && mysql_select_db($dbname));
}
return ($link);
return (FALSE);
}

connect();

$query = "select * from table where id = '$link_id'";
$result = mysql_query($result);
$this = mysql_fetch_array($result);

?>



<html><head><title>Printer Friendly</title></head>
<body>
<?php
print "$this->title <p>";
print "$this->description";
?>
</body></html>

Michael Bray
Quote Reply
Re: Printer-friendly-mod? In reply to
Hi,

can anybody tell me what the problems are with the printing? Do you have any tips what to consider to make a page printable?

I can do the perl-programming in return for the specs of html to make a page printable ( diffrent formats A4, letter etc.)

regards, alexander

Quote Reply
Re: Printer-friendly-mod? In reply to
Hi Alex,

for my personal purposes i need something like a print hack, cause i'm using Links SQL with a lot of graphics in the templates and up to six graphics stored into the database. I'd like to add a simple button like "Print this page" - if anyone uses this link, a clean page with the data and without graphics and additional colors should be shown ...

The easist way should be just to add a script like print.cgi?ID=<%ID%> and this script pulls data from the database and shows it ... but my perl experiences are nearly by zero .... :(



Quote Reply
Re: Printer-friendly-mod? In reply to
Ok,

I will post the print.cgi in the resources.
It will take 3 steps.

1. copy the print.cgi in the cgi-bin dir.
2. add the sub print_html to HTML_Templates.pm and add it to @export.
3. Make a template called print.html

But please tell me what has to be considered to make a page printable.

regards, alexander

Quote Reply
Re: Printer-friendly-mod? In reply to
Hi Alex,

this would be really great - a clean printable page should basically contain the following two things:

- any fields from the database (choosen via template)
- the name of the website
- the url to the database/link

Maybe you could send me your script via mail so i could check and extend it before you'll add this to the resources ... you may contact me at bedr@gmx.net

Regards
Chef

Quote Reply
Re: Printer-friendly-mod? In reply to
My printer friendly pages are just the text, with the URL etc, no images, banners etc. I also have this in the body tag - OnLoad="printPage()" - which makes the print page dialog pop up when the page is loaded.

ethan

Quote Reply
Re: Printer-friendly-mod? In reply to
Alex,

just a hint: your print.cgi calls the wrong template (detailed instead of print.html)



Quote Reply
Re: Printer-friendly-mod? In reply to
To make this mod work, you need to replace the line at the end of print.cgi:

EXISTING:
print &site_html_detailed ($link,{Total =>$total, CategoryName => $category_name});

SHOULD BE:
print &print_html ($link,{Total =>$total, CategoryName => $category_name});

Otherwise, it creates a detailed page rather than the print-ready page.


Quote Reply
Re: Printer-friendly-mod? In reply to
Oops...

Nice little typo..Blush

thanks for the tip.

regards, alexander