From: Sven Schöling Date: Sun, 28 Feb 2021 10:50:20 +0000 (+0100) Subject: Layout: webpages_path jetzt im Layout X-Git-Tag: kivitendo-mebil_0.1-0~9^2~103 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4abd6557575dc88d0baa0b96e689f4089560f78c;p=kivitendo-erp.git Layout: webpages_path jetzt im Layout --- 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;