From 4abd6557575dc88d0baa0b96e689f4089560f78c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Sun, 28 Feb 2021 11:50:20 +0100 Subject: [PATCH] Layout: webpages_path jetzt im Layout --- SL/Form.pm | 6 ++++-- SL/Layout/Base.pm | 4 ++++ SL/Presenter.pm | 10 +++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 630c0f290..8d8f41768 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -550,8 +550,10 @@ sub _prepare_html_template { } $language = "de" unless ($language); - if (-f "templates/webpages/${file}.html") { - $file = "templates/webpages/${file}.html"; + my $webpages_path = $::request->layout->webpages_path; + + if (-f "${webpages_path}/${file}.html") { + $file = "${webpages_path}/${file}.html"; } elsif (ref $file eq 'SCALAR') { # file is a scalarref, use inline mode diff --git a/SL/Layout/Base.pm b/SL/Layout/Base.pm index a1df9ebef..c64a99ab0 100644 --- a/SL/Layout/Base.pm +++ b/SL/Layout/Base.pm @@ -38,6 +38,10 @@ sub init_sublayouts_by_name { {} } +sub webpages_path { + "templates/webpages"; +} + sub get { $_[0]->sub_layouts; return grep { $_ } ($_[0]->sub_layouts_by_name->{$_[1]}); diff --git a/SL/Presenter.pm b/SL/Presenter.pm index b3191750c..44332bd91 100644 --- a/SL/Presenter.pm +++ b/SL/Presenter.pm @@ -45,8 +45,10 @@ sub render { # Look for the file given by $template if $template is not a reference. my $source; if (!ref $template) { + my $webpages_path = $::request->layout->webpages_path; + my $ext = $options->{type} eq 'text' ? 'txt' : $options->{type}; - $source = "templates/webpages/${template}.${ext}"; + $source = "${webpages_path}/${template}.${ext}"; croak "Template file ${source} not found" unless -f $source; } elsif (ref($template) eq 'SCALAR') { @@ -96,6 +98,8 @@ sub render { sub get_template { my ($self) = @_; + my $webpages_path = $::request->layout->webpages_path; + # Make locales.pl parse generic/exception.html, too: # $::form->parse_html_template("generic/exception") $self->{template} ||= @@ -104,10 +108,10 @@ sub get_template { ABSOLUTE => 1, CACHE_SIZE => 0, PLUGIN_BASE => 'SL::Template::Plugin', - INCLUDE_PATH => '.:templates/webpages', + INCLUDE_PATH => ".:$webpages_path", COMPILE_EXT => '.tcc', COMPILE_DIR => $::lx_office_conf{paths}->{userspath} . '/templates-cache', - ERROR => 'templates/webpages/generic/exception.html', + ERROR => "${webpages_path}/generic/exception.html", ENCODING => 'utf8', }) || croak; -- 2.20.1