Index: /trunk/cgi-bin/main.cgi
===================================================================
--- /trunk/cgi-bin/main.cgi	(revision 792)
+++ /trunk/cgi-bin/main.cgi	(revision 793)
@@ -70,9 +70,11 @@
 
 # Set up some globals
-$ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates";
-
-my $header = HTML::Template->new(filename => "header.tmpl");
-my $footer = HTML::Template->new(filename => "footer.tmpl");
-my $utilbar = HTML::Template->new(filename => "utilbar.tmpl", loop_context_vars => 1, global_vars => 1);
+$ENV{HTML_TEMPLATE_ROOT} = $thingroot;
+my @templatepath = [ "localtemplates", "templates" ];
+
+my $header = HTML::Template->new(filename => "header.tmpl", path => @templatepath);
+my $footer = HTML::Template->new(filename => "footer.tmpl", path => @templatepath);
+my $utilbar = HTML::Template->new(filename => "utilbar.tmpl", loop_context_vars => 1, global_vars => 1,
+	path => @templatepath);
 
 print "Content-type: text/html\n\n";
@@ -96,8 +98,10 @@
 
 my $page;
-if (-e "$ENV{HTML_TEMPLATE_ROOT}/$webvar{action}.tmpl") {
-  $page = HTML::Template->new(filename => "$webvar{action}.tmpl", loop_context_vars => 1, global_vars => 1);
+if (-e "$ENV{HTML_TEMPLATE_ROOT}/templates/$webvar{action}.tmpl") {
+  $page = HTML::Template->new(filename => "$webvar{action}.tmpl", loop_context_vars => 1, global_vars => 1,
+	path => @templatepath);
 } else {
-  $page = HTML::Template->new(filename => "dunno.tmpl");
+  $page = HTML::Template->new(filename => "dunno.tmpl", die_on_bad_params => 0,
+	path => @templatepath);
 }
 
@@ -230,5 +234,5 @@
 # remove the links a user is not allowed to click on.
 if ($aclerr) {
-  $page = HTML::Template->new(filename => "aclerror.tmpl");
+  $page = HTML::Template->new(filename => "aclerror.tmpl", path => @templatepath);
   $page->param(ipdbfunc => $aclmsg{$aclerr});
 }
@@ -272,5 +276,6 @@
     # Containers have a second line for the subblock metadata.
     # We need to load an alternate template for this case.
-    $page = HTML::Template->new(filename => "showsubs2.tmpl", loop_context_vars => 1, global_vars => 1);
+    $page = HTML::Template->new(filename => "showsubs2.tmpl", loop_context_vars => 1, global_vars => 1,
+	path => @templatepath);
 
     $page->param(maydel => ($IPDBacl{$authuser} =~ /d/));
