Gossamer Forum
Home : Products : Links 2.0 : Customization :

Rename all directories to end with "suffix"

(Page 2 of 2)
> >
Quote Reply
Re: [PerlFlunkie] Rename all directories to end with "suffix" In reply to
Here's the other changes...

Code:

sub build_linked_title {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.
my $input = shift;
my (@dirs, $dir, $output, $path, $last, $dir_2);
my $suffix = '_directory';
@dirs = split (/\//, $input);
my $quant = @dirs;
$last = &build_clean(pop @dirs);
if ($quant > 1) {
$last = $last . $suffix;
}

$first = $dirs[0];
foreach $dir(@dirs) {
$dir = $dir . $suffix;
}
$dirs[0] = $first;

$output = qq| <A HREF="$build_root_url/">Top</A> :|;
foreach $dir (@dirs) {
$path .= "/$dir";

$path =~ tr/[A-Z]/[a-z]/;

$dir =~ s/$suffix//g;
$dir = &build_clean ($dir);
$output .= qq| <A HREF="$build_root_url$path/">$dir</A> :|;
}
$output .= " $last";

return $output;
}


Code:

sub urlencode {
# --------------------------------------------------------
# Escapes a string to make it suitable for printing as a URL.
#
my($toencode) = shift;
my $suffix = '_directory';

$toencode =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$toencode =~ s/\%2F/\//g; # replaces a / for a space

$toencode =~ tr/[A-Z]/[a-z]/;
if ($toencode =~ /\/+/) {
$toencode = $toencode . $suffix;
}

return $toencode;
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Rename all directories to end with "suffix" In reply to
Thanks - I tried the code from your last post and seems to work fine but need to do some testing (builds an extra directory for the second level).

So, what was the post one before the last one - does it do the same thing as you indicated there that it also builds extra directories or is that any different? So, I am assuming the last one is the best we can get - we can't do without builiding extra directories in the second level - is that correct?

Thanks
Quote Reply
Re: [socrates] Rename all directories to end with "suffix" In reply to
In order to keep the URLs like you want them, the redundant directories are needed:

site.com/california/southern_california/san_diego_directory/index.html

else they will build like so:


site.com/california/southern_california_directory/san_diego_directory/index.html




Leonard
aka PerlFlunkie
> >