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

Re: Clean Category Name?

Quote Reply
Re: Clean Category Name? In reply to
Okay...what you need to do is the following:

1) Add the following sub in the DB_Utils.pm module (don't forget to reference &build_category_clean_name at the top of the file)....

Code:

sub build_category_clean_name {
# --------------------------------------------------------
# Converts a category name into something usable by a directory/URL.
#
my $name = shift;
if ($LINKS{foreign_char}) {
my @cat = split /\//, $name;
my ($output, $id, $tmp, $level);
$level = $#cat;
for (0 .. $level) {
$tmp = join "/", @cat;
$id = &get_category_id ($tmp);
if (!$id) { $tmp =~ s/[^\w\d\_\-\/]/_/g; $id = $tmp; }
$output = "$id/$output";
pop @cat;
}
$output =~ s,/$,,;
return $output;
}
elsif ($LINKS{build_directory_field}) {
my $id = &get_category_id ($name);
if (! $CATDB) {
$CATDB = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Category.def";
}
my $rec = $CATDB->get_record ($id, 'HASH');
if ($rec->{$LINKS{build_directory_field}}) { return $rec->{$LINKS{build_directory_field}}; }
else { $name =~ s/\s/_/g; $name =~ s/[^\w\d\_\-\/]/_/g; return $name; }
}
else {
return $name;
}
}


2) Then add the following codes in your sub site_html_link routine in the HTML_Templates.pm module file:

Code:

my $catname = &Links::DB_Utils::get_category_name($tags->{CategoryID});
my $category = &Links::DB_Utils::build_category_clean_name($catname);


3) Then define the following "tags" in the same sub:

Code:

catname => $catname,
category => $category


4) Then in the link.html file, add the following codes:

Code:

<a href="<%category%>"><%catname%></a>


You may have to hack the first set of codes a bit more to remove the / character from other places like the drop-down select menus.

Regards,

Eliot Lee
Subject Author Views Date
Thread Clean Category Name? ryel01 3046 Mar 18, 2001, 10:46 PM
Thread Re: Clean Category Name?
Stealth 2982 Mar 19, 2001, 8:27 AM
Thread Re: Clean Category Name?
ryel01 2972 Mar 19, 2001, 3:08 PM
Thread Re: Clean Category Name?
Stealth 2974 Mar 19, 2001, 5:45 PM
Thread Re: Clean Category Name?
ryel01 2987 Mar 19, 2001, 5:59 PM
Post Re: Clean Category Name?
Stealth 2966 Mar 19, 2001, 6:08 PM