Gossamer Forum
Home : Products : Gossamer Links : Discussions :

detailed info for categories

Quote Reply
detailed info for categories
hello
is there a mod or something to create detai;ed templates for categories.
Pugdog wrote a detailed.cgi script that makes detailed templated dynamically.

I want that option to show visitors some info about a category and show them which subcategories & amount of links.

Quote Reply
Re: detailed info for categories In reply to
Use page.cgi...already built-in with LINKS SQL.

Regards,

Eliot Lee
Quote Reply
Re: detailed info for categories In reply to
I think he's asking if there can be an extra page that gives increased detail about the categories.

The easiest way is to expand the "category.html" file, and add extra information to the first page. I did this on one site, but it was for 1.1x not the NG version. All you'll need to do is set a "first_page" tag, to activate the details.

The other way to do this: You can modify detail_page.cgi to display a category -- basically pull the codes out of page.cgi into the new file, and clean it up a bit. Then add extra tags to the category_detail.html file. Then have category_detail.cgi print to that template instead. All the links will still be both absolute and relatively linked, but this will be an extra "detour" if you want to use it.



PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: detailed info for categories In reply to
right that's exactly what I mean.

and i a=want to call the script linke this

detail_category.cgi?ID=<%category_id%>

I tried this before with detailed.cgi but this does not work.

I used this code, and chanced all link codes into the category codes found in page.cgi

============================================================

#!/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 '/home/ridesworld/www/cgi-bin/links/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;

===========================================================

Ok I grab this code from you Pugdog.

could you give me an example with the category codes in it.
It begin to failed near

## 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}");

Cheers,

Ericho


Quote Reply
Re: detailed info for categories In reply to
Ok I find another solution to get detailed info for categories.
It is not the best way but it works fine!

1.
copy the sub generate_category_page from page.cgi
and create with this code it's own cgi-script.
rename
print Links::Build::build ('category', { id => $id, nh => $page_num });
in
print Links::Build::build ('detailcategory', { id => $id, nh => $page_num });

2. copy the $SUBS{build_category} subroutine from build.pm
and paste it below in build.pm with another name,
$SUBS{build_detailcategory}

3. copy site_html_category from SiteHTML.pm and paste it in
the same file with another name, (same name as the new subroutine in build.pm

open your cgi-script from your browser like this:
detailcategory.cgi?g=categoryname

seee example on:
http://www.ridesworld.com/cgi-bin/links/catdetailed.cgi?g=testcategory






Quote Reply
Re: detailed info for categories In reply to
How about:

1. Create a new template detailed_category.html
2. Add a template global called category_info that looks like:

sub {
my $tags = shift;
my $cat_db = $DB->table('Category');
my $id = $tags->{ID};
my $cat_info = $cat_db->get($id, 'HASH');
return $cat_info;
}

3. Go to: page.cgi?p=detailed_category&ID=123

and that will display the detailed_category.html template and on that page you will have all the fields available for that category.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: detailed info for categories In reply to
A bit simpler (and more complete) than my solution #2, but it won't statically link pages like detail_page.cgi will. You'll end up in dynamic mode whether or not you were in dynamic mode when you hit that page.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: detailed info for categories In reply to
It should as long as you don't pass in d=1. On my copy if you go to:

page.cgi?p=search

you'll get the search.html template, and the links will still be to the static html pages, not rewritten to page.cgi.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: detailed info for categories In reply to
I will try your option soon alex,
it is much easier as the option I suggest.
the next ridesworld version will be shown complete in dynamic mode so i put &d=1 behind some links that need it.

Yours,

Ridesworld


Quote Reply
Re: detailed info for categories In reply to
hello
I tried the option that Alex give
but i have this error

Invalid method: site_html_category_info?ID=1 (category_info?ID=1.html)

what should i do now?

Quote Reply
Re: detailed info for categories In reply to
The link should be page.cgi?p=detailed_category

It needs to match up to what you named your template.

Cheers,

Alex

--
Gossamer Threads Inc.