Layout: webpages_path jetzt im Layout
authorSven Schöling <s.schoeling@googlemail.com>
Sun, 28 Feb 2021 10:50:20 +0000 (11:50 +0100)
committerSven Schöling <s.schoeling@googlemail.com>
Fri, 25 Jun 2021 13:51:32 +0000 (15:51 +0200)
SL/Form.pm
SL/Layout/Base.pm
SL/Presenter.pm

index 630c0f2..8d8f417 100644 (file)
@@ -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
index a1df9eb..c64a99a 100644 (file)
@@ -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]});
index b319175..44332bd 100644 (file)
@@ -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;