Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIX Template discovery on themed Layout templates

Was failing when 'main' template only exists in theme,
but 'Layout' template only exists in module.
  • Loading branch information...
commit 5efae23cb29158c109b80683d218fc2d7ce51f71 1 parent cef955c
Ingo Schommer chillu authored
8 core/manifest/TemplateLoader.php
View
@@ -75,15 +75,15 @@ public function findTemplates($templates, $theme = null) {
}
if ($found = $this->getManifest()->getCandidateTemplate($template, $theme)) {
- if ($type && isset($found[$type])) {
+ if ($type && isset($found[$type])) {
$found = array(
'main' => $found[$type]
);
+ }
+
+ $result = array_merge($found, $result);
}
-
- $result = array_merge($found, $result);
}
- }
return $result;
}
4 core/manifest/TemplateManifest.php
View
@@ -115,11 +115,11 @@ public function getCandidateTemplate($name, $theme = null) {
if ($this->project && isset($candidates[$this->project])) {
$found = $candidates[$this->project];
} else if ($theme && isset($candidates['themes'][$theme])) {
- $found = $candidates['themes'][$theme];
+ $found = array_merge($candidates, $candidates['themes'][$theme]);
} else {
- unset($candidates['themes']);
$found = $candidates;
}
+ if(isset($found['themes'])) unset($found['themes']);
return $found;
}
7 tests/core/manifest/TemplateLoaderTest.php
View
@@ -42,6 +42,13 @@ public function testFindTemplates() {
);
$this->assertEquals($expectCustomPage, $loader->findTemplates(array('CustomPage', 'Page')));
+
+ // 'main' template only exists in theme, and 'Layout' template only exists in module
+ $expectCustomThemePage = array(
+ 'main' => "$base/themes/theme/templates/CustomThemePage.ss",
+ 'Layout' => "$base/module/templates/Layout/CustomThemePage.ss"
+ );
+ $this->assertEquals($expectCustomThemePage, $loader->findTemplates(array('CustomThemePage', 'Page'), 'theme'));
}
public function testFindTemplatesApplicationOverridesModule() {
9 tests/core/manifest/TemplateManifestTest.php
View
@@ -47,6 +47,13 @@ public function testGetTemplates() {
'subfolder' => array(
'main' => "{$this->base}/module/subfolder/templates/Subfolder.ss"
),
+ 'customthemepage' => array (
+ 'Layout' => "{$this->base}/module/templates/Layout/CustomThemePage.ss",
+ 'themes' =>
+ array(
+ 'theme' => array('main' => "{$this->base}/themes/theme/templates/CustomThemePage.ss",)
+ )
+ ),
'include' => array('themes' => array(
'theme' => array(
'Includes' => "{$this->base}/themes/theme/templates/Includes/Include.ss"
@@ -66,7 +73,7 @@ public function testGetTemplates() {
ksort($expectTests);
ksort($manifest);
ksort($manifestTests);
-
+
$this->assertEquals(
$expect, $manifest,
'All templates are correctly loaded in the manifest.'
0  tests/core/manifest/fixtures/templatemanifest/module/templates/Layout/CustomThemePage.ss
View
No changes.
0  tests/core/manifest/fixtures/templatemanifest/themes/theme/templates/CustomThemePage.ss
View
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.