Breadcrumb trails in Bricolage

Ovid on 2005-12-03T18:21:37

I've decided it's time to convert my personal Web site to Bricolage. So far, I've been quite happy with it. I'm using the latest development version, Bricolage 1.9.1, "peeves", and so far I've been quite delighted with it.

Previously I had been using a modified version of static Web site generating code from the Perl Template Toolkit book and it was useful, but I really want the full power of Bricolage. No more editing XML files for me!

My Web site has a "breadcrumb" trail in the top section and I wanted to replicate that. It was pleasantly easy.

my $separator = " > ";

my $make_link = sub {
  my ($uri, $name) = @_;
  return qq{$name};
};

my $uri  = $burner->best_uri($story)->as_string;
my $name = $story->get_title;

my @trail = $make_link->($uri, $name);

my $category = $story->get_primary_category;
while ($category) {
  my $cat_name = $category->get_name;
  my $cat_uri  = $category->get_uri;
  unshift @trail => $make_link->($cat_uri, $cat_name);
  $category = $category->get_parent;
}
return $separator . join $separator => @trail;

In other news, I've just uploaded Sub::Signatures 0.21 to the CPAN. If you've ever wanted Perl subroutines to have signatures with multi-method dispatch (even for regular subs), check it out.


Template archive

mroch on 2005-12-03T19:21:00

There used to be a template for that in the Bricolage template archive (http://bricolage.cc/templates/story/breadcrumbs.mc) but it appears to be blank to me. You should send that to users@ so that David can put it in the archive.