Subject: | Multiple template paths |
Here is a patch for Maypole::View::Base to allow the specification of multiple template paths in template_root().
This functionality has been requested before on the mailing list. It is useful when you want to serve header, footer, etc from site A while defaulting to site B for templates such as "list", "view", etc.
This patch should be fully backward compatible. I have been using it for several weeks without problems.
--- Base_orig.pm Tue Jun 28 13:48:19 2005
+++ Base.pm Tue Jun 28 13:49:25 2005
@@ -10,15 +10,22 @@
sub paths {
my ( $self, $r ) = @_;
my $root = $r->config->template_root || $r->get_template_root;
- return (
- $root,
- (
- $r->model_class
- && File::Spec->catdir( $root, $r->model_class->moniker )
- ),
- File::Spec->catdir( $root, "custom" ),
- File::Spec->catdir( $root, "factory" )
- );
+ if(ref($root) ne 'ARRAY') {
+ $root = [ $root ];
+ }
+ my @output = ();
+ foreach my $path (@$root) {
+ push(@output, $path);
+ push(@output,
+ (
+ $r->model_class
+ && File::Spec->catdir( $path, $r->model_class->moniker )
+ )
+ );
+ push(@output, File::Spec->catdir( $path, "custom" ));
+ push(@output, File::Spec->catdir( $path, "factory" ));
+ }
+ return @output;
}
sub vars {