mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX: ContentController::getViewer() not returning all found templates (fixes #1244)
This commit is contained in:
parent
f55b22bd75
commit
10b2fdc318
@ -402,15 +402,15 @@ HTML;
|
||||
if($action == "index") $action = "";
|
||||
else $action = '_' . $action;
|
||||
|
||||
$templates = array_merge(
|
||||
// Find templates by dataRecord
|
||||
$templates = SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree");
|
||||
|
||||
SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"),
|
||||
// Next, we need to add templates for all controllers
|
||||
$templates += SSViewer::get_templates_by_class(get_class($this), $action, "Controller");
|
||||
|
||||
SSViewer::get_templates_by_class(get_class($this), $action, "Controller"),
|
||||
// Fail-over to the same for the "index" action
|
||||
$templates += SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree");
|
||||
$templates += SSViewer::get_templates_by_class(get_class($this), "", "Controller");
|
||||
SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"),
|
||||
SSViewer::get_templates_by_class(get_class($this), "", "Controller")
|
||||
);
|
||||
|
||||
return new SSViewer($templates);
|
||||
}
|
||||
|
@ -168,6 +168,14 @@ class ContentControllerTest extends FunctionalTest {
|
||||
// to say the default Page.ss template
|
||||
$response = $self->get($page->RelativeLink("testwithouttemplate"));
|
||||
$self->assertEquals("Page", $response->getBody());
|
||||
|
||||
// Test that an action with a template will render the both action template *and* the
|
||||
// correct parent template
|
||||
$controller = new ContentController($page);
|
||||
$viewer = $controller->getViewer('test');
|
||||
$templateList = array('ContentControllerTestPage_test', 'Page');
|
||||
$expected = SS_TemplateLoader::instance()->findTemplates($templateList, 'controllertest');
|
||||
$self->assertEquals($expected, $viewer->templates());
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user