From cb1f2c60c06f6029c54acb087090aa62469554ba Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Sun, 3 Aug 2014 09:41:37 -0300 Subject: [PATCH] Bug 12539: Follow up to fix fallback theme The is a problem in the logic, fallback must be: 1. Requested (theme, lang, tmpl) a. return (theme, lang, tmpl), if not b. return (fallback, lang, tmpl), if not c. return (theme, 'en', tmpl), if not as last resort d. return (fallback, 'en', tmpl) Previous patch missed option 'c', worked for CCSR but not bootstrap, sorry. Signed-off-by: Petter Goksoyr Asen Signed-off-by: Jonathan Druart Signed-off-by: Chris Cormack --- C4/Templates.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index 2c5771820c..879249a386 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -256,14 +256,18 @@ sub themelanguage { my $fallback = C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'OPACFallback' ); push @themes, $fallback; - # Try to find first theme for the selected language + # Try to find first theme for the selected theme/lang, then for fallback/lang for my $theme (@themes) { if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { return ($theme, $lang, \@themes); } } - # Otherwise, return fallback theme in English 'en' - return ($fallback, 'en', \@themes); + # Otherwise return theme/'en', last resort fallback/'en' + for my $theme (@themes) { + if ( -e "$htdocs/$theme/en/modules/$tmpl" ) { + return ($theme, 'en', \@themes); + } + } } -- 2.39.5