Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Saturday December 03, 2005
01:21 PM

Breadcrumb trails in Bricolage

[ #27842 ]

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{<a href="$uri">$name</a>};
};

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.