Revision 25205ac9
Von Sven Schöling vor etwa 2 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
555 | 555 |
} |
556 | 556 |
$language = "de" unless ($language); |
557 | 557 |
|
558 |
my $webpages_path = $::request->layout->webpages_path; |
|
558 |
my $webpages_path = $::request->layout->webpages_path; |
|
559 |
my $webpages_fallback = $::request->layout->webpages_fallback_path; |
|
559 | 560 |
|
560 |
if (-f "${webpages_path}/${file}.html") { |
|
561 |
$file = "${webpages_path}/${file}.html"; |
|
561 |
my @templates = first { -f } map { "${_}/${file}.html" } grep { defined } $webpages_path, $webpages_fallback; |
|
562 | 562 |
|
563 |
if (@templates) { |
|
564 |
$file = $templates[0]; |
|
563 | 565 |
} elsif (ref $file eq 'SCALAR') { |
564 | 566 |
# file is a scalarref, use inline mode |
565 | 567 |
} else { |
SL/Layout/Base.pm | ||
---|---|---|
44 | 44 |
"templates/webpages"; |
45 | 45 |
} |
46 | 46 |
|
47 |
sub webpages_fallback_path { |
|
48 |
} |
|
49 |
|
|
47 | 50 |
sub html_dialect { |
48 | 51 |
'transitional' |
49 | 52 |
} |
... | ... | |
358 | 361 |
stylesheets where the templates are so incompatible that a complete fork of the |
359 | 362 |
templates dir is sensible. |
360 | 363 |
|
364 |
=item * webpages_fallback_path |
|
365 |
|
|
366 |
Allows partial template sets to fallback to other paths in case a template |
|
367 |
wasn't found. Intended to be used in conjunction with L</webpages_path>. |
|
368 |
|
|
369 |
Note: in case a template can't be found at all, generic/error.html will be |
|
370 |
rendered, and the fallback doesn't work in this case. |
|
371 |
|
|
372 |
|
|
361 | 373 |
=item * allow_stylesheet_fallback |
362 | 374 |
|
363 | 375 |
Defaults to true. The default behaviour is that stylesheets not found in the |
SL/Presenter.pm | ||
---|---|---|
6 | 6 |
|
7 | 7 |
use Carp; |
8 | 8 |
use Template; |
9 |
use List::Util qw(first); |
|
9 | 10 |
|
10 | 11 |
use SL::Presenter::EscapedText qw(is_escaped); |
11 | 12 |
|
... | ... | |
45 | 46 |
# Look for the file given by $template if $template is not a reference. |
46 | 47 |
my $source; |
47 | 48 |
if (!ref $template) { |
48 |
my $webpages_path = $::request->layout->webpages_path; |
|
49 |
my $webpages_path = $::request->layout->webpages_path; |
|
50 |
my $webpages_fallback = $::request->layout->webpages_fallback_path; |
|
49 | 51 |
|
50 | 52 |
my $ext = $options->{type} eq 'text' ? 'txt' : $options->{type}; |
51 |
$source = "${webpages_path}/${template}.${ext}"; |
|
52 |
croak "Template file ${source} not found" unless -f $source; |
|
53 |
|
|
54 |
$source = first { -f } map { "${_}/${template}.${ext}" } grep { defined } $webpages_path, $webpages_fallback; |
|
55 |
|
|
56 |
croak "Template file ${template} not found" unless $source; |
|
53 | 57 |
|
54 | 58 |
} elsif (ref($template) eq 'SCALAR') { |
55 | 59 |
# Normal scalar reference: hand over to Template |
... | ... | |
98 | 102 |
sub get_template { |
99 | 103 |
my ($self) = @_; |
100 | 104 |
|
101 |
my $webpages_path = $::request->layout->webpages_path; |
|
105 |
my $webpages_path = $::request->layout->webpages_path; |
|
106 |
my $webpages_fallback = $::request->layout->webpages_fallback_path; |
|
107 |
|
|
108 |
my $include_path = join ':', grep defined, $webpages_path, $webpages_fallback; |
|
102 | 109 |
|
103 | 110 |
# Make locales.pl parse generic/exception.html, too: |
104 | 111 |
# $::form->parse_html_template("generic/exception") |
... | ... | |
108 | 115 |
ABSOLUTE => 1, |
109 | 116 |
CACHE_SIZE => 0, |
110 | 117 |
PLUGIN_BASE => 'SL::Template::Plugin', |
111 |
INCLUDE_PATH => ".:$webpages_path",
|
|
118 |
INCLUDE_PATH => ".:$include_path",
|
|
112 | 119 |
COMPILE_EXT => '.tcc', |
113 | 120 |
COMPILE_DIR => $::lx_office_conf{paths}->{userspath} . '/templates-cache', |
114 | 121 |
ERROR => "${webpages_path}/generic/exception.html", |
Auch abrufbar als: Unified diff
Layout: webpages_fallback_path Mechanismus