[Catalyst] Branding - or path prefix
Bill Moseley
moseley at hank.org
Tue Aug 2 01:59:05 CEST 2005
Phaylon gave a few more tips and this hack kinda works.
In the application base class:
sub prepare_action {
my ( $c, @rest ) = @_;
# Hack the path
my @path_segments = split m[/], $c->req->path;
my $prefix = shift @path_segments;
$c->req->path( join '/', @path_segments );
my $r = $c->NEXT::prepare_action( @rest );
# For making URLs with prefix back on
$c->stash->{myself} = join '/', $prefix, split( m[/], $c->req->action );
return $r;
}
Seems like an ugly hack -- messing with $c->req->path, that is.
Future breakage?
Note that $c->stash->{myself} is only correct for "Local" actions,
which is what I'm using mostly for creating links back to the same
controller. That's not really what "action" is, though. But, I'm not
sure how else to make a self-referring URL (relative to the
controller) based on info in $c.
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list