Gossamer Forum
Home : Products : Links 2.0 : Customization :

New detailed pages

Quote Reply
New detailed pages
I wanted to build second detailed pages ("View printable version" in these case). Can anyone help me doing that? I'm not a PERL guru, so without complete directions I won't be able to do that.
Quote Reply
Re: New detailed pages In reply to
Thanks.
And you assumed correctly twice -- I wanted a second set of detailed pages and I'm using templates (I don't know PERL that good to mess up with site_html.pl).

I think someone should put this mod into FAQ or something. If it's gonna work... :-) I'll check that tomorrow.

[This message has been edited by Uded P (edited March 05, 2000).]
Quote Reply
Re: New detailed pages In reply to
Hi!

I'm going to assume that you want to build the second set of detailed pages into a new directory. I'm going to name it "printfriend" but you can name it whatever you like of course (just change the name in the code). I'm also going to assume you're using templates - only because I'm not really qualified to do a non-templates one...very sorry!

First, open links.cfg. We're going to determine where the printable pages are built.

Find:
Code:
$build_detailed = 0;
$build_detail_path = "$build_root_path";
$build_detail_url = "$build_root_url";

and after that add

Code:
$build_printfriend_path = "$build_root_path/printfriend";
$build_printfriend_url = "$build_root_url/printfriend";


Next, open nph-build.cgi. We're going to copy the "detailed" subroutines and rename them for printpage.
(note: I'm doing this for sub build_all. If you use build staggered, and probably just as good practice, you'll need to duplicate and then rename the copy of the detailed information in build staggered as well.)

Where you see:
Code:
# Generate detailed view pages.
if ($build_detailed) {
print "Generating detailed view pages . . . \n";
&build_detailed_view;
print "Done\n\n";
}

Add this after:

Code:
# Generate printable detailed view pages.
if ($build_detailed) {
print "Generating printable detailed view pages . . . \n";
&build_detailed_printable;
print "Done\n\n";
}

Then, also in nph-build.cgi, beneath sub build_detailed_view (the *whole* subroutine, not just that first line), add:

sub build_detailed_printable {
# --------------------------------------------------------
# This routine builds a printable verson of the detailed pages
#
my (@values, $id, %rec, $count);
if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);
$title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");
open (DETAIL, ">$build_printfriend_path/$id$build_extension") or &cgierr ("Unable to build detail page: $build_printfriend_path/$id$build_extension. Reason: $!");
print DETAIL &site_html_printfriend (%rec);
close DETAIL;
$use_html ?
print qq~<a href="$build_comments_url/$id$build_extension" target="_blank">$id</a> ~ :
print qq~$id ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}

Open site_html_templates.pl. (if you use templates, that is!) After:

Code:
sub site_html_detailed {
# --------------------------------------------------------
# This routine will build a single page per link. It's only
# really useful if you have a long review for each link --
# or more information then can be displayed in a summary.
#
my %rec = @_;
return &load_template ('detailed.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
%rec,
%globals
} );

Add

Code:
sub site_html_printfriend {
# --------------------------------------------------------
# This routine will build a printable version
#of the detailed pages.

my %rec = @_;
return &load_template ('printfriend.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
%rec,
%globals
} );

Then, finally, you'll want to create the printer-friendly template named printfriend.html in your templates directory.

I hope that helps!!! If you don't use templates, the principle is the same - basically what you're doing is duplicating the processes that build the detailed pages and renaming them so that this happens twice in two different places.

Best,
Kate Smile

[This message has been edited by Kate42 (edited March 05, 2000).]

[This message has been edited by Kate42 (edited March 05, 2000).]
Quote Reply
Re: New detailed pages In reply to
The easier thing to do is use Widgetz's detail.cgi script for both to reduce disk space.

It is located at:

www.widgetz.com/detail.txt

The only file that you need to edit is the link.html file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: New detailed pages In reply to
Hey, but I don't care about disk space Smile I got 40 GB of hard drive for my personal use Smile Afetr all, it's my sever.

But I'll go and see that program anyway. Maybe it'll be better...
Quote Reply
Re: New detailed pages In reply to
Well, a large majority of LINKS 2.0 users and owners of web domains are on virtual accounts, so for their benefit I posted my Reply. Disk space may not be something for you to worry about...but it is a major consideration for many other LINKS 2.0 users.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums