From c619d5afbabd00bd0b89a9341a05a0cf7f6cefc8 Mon Sep 17 00:00:00 2001 From: tonnesen Date: Tue, 14 May 2002 19:34:44 +0000 Subject: [PATCH] Modifications to use new template directory structure. Removed hard coded includes directory in templates. Note that TMPL_INCLUDE tags in a template will now use the koha.conf includes variable as a search path, so only the filename needs to be used. --- html-template/search.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/html-template/search.pl b/html-template/search.pl index 406e14c981..5756278204 100755 --- a/html-template/search.pl +++ b/html-template/search.pl @@ -30,17 +30,15 @@ while () { } my $includes=$configfile{'includes'}; ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes"); -my $templatebase="$includes/templates/catalogue/searchresults/"; -my $templatename=$query->param('template'); +my $templatebase="catalogue/searchresults.tmpl"; my $startfrom=$query->param('startfrom'); ($startfrom) || ($startfrom=0); -($templatename) || ($templatename='default.tmpl'); -$templatename=picktemplate($templatebase); +my $theme=picktemplate($includes, $templatebase); -my $template = HTML::Template->new(filename => "$templatebase$templatename", die_on_bad_params => 0); +my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]); ##my @results; #my $sth=$dbh->prepare("select * from biblio where author like 's%' order by author limit $startfrom,20"); @@ -67,19 +65,21 @@ my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20); my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0); $template->param(nextstartfrom => $nextstartfrom); $template->param(prevstartfrom => $prevstartfrom); -$template->param(template => $templatename); $template->param(SEARCH_RESULTS => $resultsarray); +$template->param(includesdir => $includes); print "Content-Type: text/html\n\n", $template->output; sub picktemplate { - my ($base) = @_; + my ($includes, $base) = @_; my $templates; - opendir (D, $base); + opendir (D, "$includes/templates"); my @dirlist=readdir D; foreach (@dirlist) { - (next) unless (/\.tmpl$/); + (next) if (/^\./); + #(next) unless (/\.tmpl$/); + (next) unless (-e "$includes/templates/$_/$base"); $templates->{$_}=1; } my $sth=$dbh->prepare("select value from systempreferences where variable='template'"); @@ -89,7 +89,7 @@ sub picktemplate { if ($templates->{$preftemplate}) { return $preftemplate; } else { - return 'default.tmpl'; + return 'default'; } } -- 2.39.5