mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Template discovery on themed Layout templates
Was failing when 'main' template only exists in theme, but 'Layout' template only exists in module.
This commit is contained in:
parent
cef955c8b9
commit
5efae23cb2
@ -115,11 +115,11 @@ class SS_TemplateManifest {
|
|||||||
if ($this->project && isset($candidates[$this->project])) {
|
if ($this->project && isset($candidates[$this->project])) {
|
||||||
$found = $candidates[$this->project];
|
$found = $candidates[$this->project];
|
||||||
} else if ($theme && isset($candidates['themes'][$theme])) {
|
} else if ($theme && isset($candidates['themes'][$theme])) {
|
||||||
$found = $candidates['themes'][$theme];
|
$found = array_merge($candidates, $candidates['themes'][$theme]);
|
||||||
} else {
|
} else {
|
||||||
unset($candidates['themes']);
|
|
||||||
$found = $candidates;
|
$found = $candidates;
|
||||||
}
|
}
|
||||||
|
if(isset($found['themes'])) unset($found['themes']);
|
||||||
|
|
||||||
return $found;
|
return $found;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,13 @@ class TemplateLoaderTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expectCustomPage, $loader->findTemplates(array('CustomPage', 'Page')));
|
$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() {
|
public function testFindTemplatesApplicationOverridesModule() {
|
||||||
|
@ -47,6 +47,13 @@ class TemplateManifestTest extends SapphireTest {
|
|||||||
'subfolder' => array(
|
'subfolder' => array(
|
||||||
'main' => "{$this->base}/module/subfolder/templates/Subfolder.ss"
|
'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(
|
'include' => array('themes' => array(
|
||||||
'theme' => array(
|
'theme' => array(
|
||||||
'Includes' => "{$this->base}/themes/theme/templates/Includes/Include.ss"
|
'Includes' => "{$this->base}/themes/theme/templates/Includes/Include.ss"
|
||||||
|
Loading…
Reference in New Issue
Block a user