Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision eb24ae59

Von Sven Schöling vor mehr als 2 Jahren hinzugefügt

  • ID eb24ae59e75fe41ed5022077449999adab57fa42
  • Vorgänger a2dc42cf
  • Nachfolger b7aa64b4

Layout: webpages_fallback_path Mechanismus

Unterschiede anzeigen:

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
42 42
  "templates/webpages";
43 43
}
44 44

  
45
sub webpages_fallback_path {
46
}
47

  
45 48
sub html_dialect {
46 49
  'transitional'
47 50
}
......
354 357
stylesheets where the templates are so incompatible that a complete fork of the
355 358
templates dir is sensible.
356 359

  
360
=item * webpages_fallback_path
361

  
362
Allows partial template sets to fallback to other paths in case a template
363
wasn't found. Intended to be used in conjunction with L</webpages_path>.
364

  
365
Note: in case a template can't be found at all, generic/error.html will be
366
rendered, and the fallback doesn't work in this case.
367

  
368

  
357 369
=item * allow_stylesheet_fallback
358 370

  
359 371
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