Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

category global gone wrong

Quote Reply
category global gone wrong
I am using this global to list all my subcategories on the home page, by passing the main category in url
so instead of
I am expecting this

In Setup, under Build options, for build_category_dynamic, I choose Advanced and used Name instead of Full_Name,
It worked partially because I now have

instead of

What do I have to do to take out the %20 and use _ instead

I don't think the search engines will favor a url with %20 in it.

here is global

sub {
my ($category,$output);
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Name Asc','LIMIT 1000') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Name'], GT::SQL::Condition->new('FatherID','>','0') ) || return $GT::SQL::error;
while (my ($fatherid,$full_name) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q| |;
$back .= $cut[$#cut];
$output .= qq|<div> <a href="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|/index.html" ><font class="right_newcats">$back</font></a></div>|. "\n";
return \$output;