mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1818 from PutmanMedia/pulls/themed-main-templates
FIX Template discovery on themed Layout templates
This commit is contained in:
commit
284245c3de
@ -75,15 +75,15 @@ class SS_TemplateLoader {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -115,11 +115,11 @@ class SS_TemplateManifest {
|
||||
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;
|
||||
}
|
||||
|
@ -42,6 +42,13 @@ class TemplateLoaderTest extends SapphireTest {
|
||||
);
|
||||
|
||||
$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() {
|
||||
|
@ -47,6 +47,13 @@ class TemplateManifestTest extends SapphireTest {
|
||||
'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 @@ class TemplateManifestTest extends SapphireTest {
|
||||
ksort($expectTests);
|
||||
ksort($manifest);
|
||||
ksort($manifestTests);
|
||||
|
||||
|
||||
$this->assertEquals(
|
||||
$expect, $manifest,
|
||||
'All templates are correctly loaded in the manifest.'
|
||||
|
Loading…
Reference in New Issue
Block a user