when searching for a path template that's not in the web config, search up the path...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 Jan 2009 18:37:26 +0000 (18:37 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 Jan 2009 18:37:26 +0000 (18:37 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11878 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm

index 7208860..073743c 100644 (file)
@@ -111,14 +111,26 @@ sub find_template {
 
         # see if we can magically find the template based on the path and default extension
         my $ext = $ctx->{default_template_extension};
-        for my $tpath (@{$ctx->{template_paths}}) {
-            my $fpath = "$tpath/$skin/$path.$ext";
-            $r->log->debug("looking at possible template $fpath");
-            if(-r $fpath) {
-                $template = "$path.$ext";
-                last;
+
+        my @parts = split('/', $path);
+        my $localpath = $path;
+        my @args;
+        while(@parts) {
+            last unless $localpath;
+            for my $tpath (@{$ctx->{template_paths}}) {
+                my $fpath = "$tpath/$skin/$localpath.$ext";
+                $r->log->debug("looking at possible template $fpath");
+                if(-r $fpath) {
+                    $template = "$localpath.$ext";
+                    last;
+                }
             }
-        }
+            last if $template;
+            push(@args, pop @parts);
+            $localpath = '/'.join('/', @parts);
+        } 
+
+        $page_args = [@args];
 
         # no template configured or found
         unless($template) {