Jochen Topf wrote:
> I am trying to put a breadcrumbs navigation line on an Embperl web site.
> Something like this: 'Home / Publications / Papers / UNIX', with a link
> behind every word but the last one, which describes the current page.
>
> The idea was to have a Perl function in every page which returns the short
> title for this page. Everything else should work automatically. Finding
> the list of parents should work like this:
>
> /pub/papers/unix.html -> parent is /pub/papers/index.html
> /pub/papers/index.html -> parent is /pub/index.html
> /pub/index.html -> parent is /index.html
>
> i.e. if the filename is index.html look for index.html in the parent directory,
> if it is not, look for index.html in the current directory.
Here's a function which I did for my site, which does pretty much what
you're talking about:
sub navigation_path
{
my ($self, $domain, $include_links) = @_;
# Get the script path
my @path = split ('/', $ENV{SCRIPT_NAME});
my $result = (scalar (@path) > 1 &&
$include_links &&
$path[1] ne "index.html")
? qq{<A HREF="/">$domain</A> / }
: qq{$domain / };
my $url = "/";
for (my $i = 1; $i < scalar(@path); $i++)
{
if ($path[$i] =~ /(\w+\.html)$/)
{
if ($path[$i] ne "index.html")
{
$result .= qq{$path[$i]};
}
}
else
{
$url .= "$path[$i]/";
$result .= $path[$i + 1] ne "index.html" &&
$include_links
? qq{<A HREF="$url">$path[$i]</A> / }
: $include_links
? qq{<BIG><B>$path[$i]</B></BIG> / }
: qq{$path[$i] / };
}
}
return $result;
}
You would use this like so, from your base.epl (if you're using
EmbperlObject). It works automatically from whatever the current
document directory is:
[+ navigation_path ('mydomain.com', 1) +]
Pass 0 for the 2nd param to suppress links.
Hope this helps...
-Neil
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]