Here is an expanded version of detailed.cgi (which printed detail pages as static pages). This version can accept ID=nnn or Page=template
It might need some debugging, as I didn't run it, but idea is pretty clear.
It first checks for either ID or Page, and doesn't care if both are passed in. If both are passed in, ID takes precedence over Page.
I don't know if this version will run without a fix here or there, since I added the 'page' support to the basic 'ID' support of detailed.cgi
Code:
#!/usr/local/bin/perl
# ==================================================================
# Links SQL - enhanced directory management system
#
# Website : http://gossamer-threads.com/
# Support : http://gossamer-threads.com/scripts/support/
# Revision : $Id: page.cgi,v 1.8 2000/11/09 21:16:57 alex Exp $
#
# Copyright (c) 2000
Gossamer Threads Inc. All Rights Reserved.
# Redistribution in part or in whole strictly prohibited. Please
# see LICENSE file for full details.
# ==================================================================
#
# This program expects EITHER an ID or a Page passed in.
# ID is checked for a valid ## and existing record, and if ti exists,
# a "detailed" page is printed for that link, as if it were a static page.
# ie: no url translations.
# if no ID is passed in, Page is checked, and if it exists, it's passed
# to the print template routine, which does the existence checking
#
# ==================================================================
use strict;
use lib '/path/to/your/admin';
use Links qw/$IN $DB $CFG $USER/;
use Links::Build;
use Links::SiteHTML;
use vars qw/$LINKDB $CATDB/;
main();
sub main {
# --------------------------------------------------------------
# Wrap in a subroutine to prevent possible mod_perl probs.
#
# Create our database objects.
$LINKDB ||= $DB->table('Links');
$CATDB ||= $DB->table('Category');
if ($IN->param('ID')) {
&generate_detailed_page ()
} else {
&generate_detailed_page()
}
}
sub generate_detailed_page {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my ($page, $id, $link);
$id = $IN->param('ID');
$page = $IN->param('Page');
if (!$id and !$page) {
print $IN->header();
print Links::SiteHTML::display ('error', { error => Links::language('PAGE_INVALIDDETAIL', $id) });
return;
}
($id) && ($link = $LINKDB->get ($id, 'HASH'));
if ($id and !$link) {
print $IN->header();
print Links::SiteHTML::display ('error', { error => Links::language('PAGE_INVALIDDETAIL', $id) } );
return;
}
## need to do some housekeeping, and set up some variables:
my ($cat_id, $cat_name) = %{$LINKDB->get_categories ($link->{'ID'})}; ## Returns the category name & ID from link ID
$link->{'title_linked'} = Links::Build::build ('title_linked', "$cat_name/$link->{Title}");
## Fix up the HTML references
my ($begin, $url, $output); ## setting up for a very, very complicated regex, taken from Links.pm clean_output
$link->{'title_linked'} =~ s!(<a[^>]+href\s*=\s*["']*)$CFG->{build_root_url}/?([^"'>]*)!
($begin, $url) = ($1, $2);
$output = "$1$CFG->{db_cgi_url}/page.cgi?g=" . $IN->escape($2);
$output;
!eisog;
if ($link) {
print $IN->header();
print Links::SiteHTML::display ('detailed', $link);
return;
} elsif ($page) {
print $IN->header();
print Links::SiteHTML::display ($page);
return;
} else {
print $IN->header();
($id) ?
print Links::SiteHTML::display ('error', { error => Links::language('PAGE_INVALIDDETAIL', $id) } ) :
print Links::SiteHTML::display ('error', { error => Links::language('PAGE_INVALIDDETAIL', $page) } );
return;
}
}
1;
PUGDOGŪ Enterprises, Inc.