mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #941 from sminnee/fix-content-getviewer
FIX: Fix failover to index template in ContentController::getViewer()
This commit is contained in:
commit
9674b2efb4
@ -404,6 +404,10 @@ HTML;
|
|||||||
// Next, we need to add templates for all controllers
|
// Next, we need to add templates for all controllers
|
||||||
$templates += SSViewer::get_templates_by_class(get_class($this), $action, "Controller");
|
$templates += 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");
|
||||||
|
|
||||||
return new SSViewer($templates);
|
return new SSViewer($templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,11 @@ class ContentControllerTest extends FunctionalTest {
|
|||||||
|
|
||||||
$response = $this->get($page->RelativeLink("test"));
|
$response = $this->get($page->RelativeLink("test"));
|
||||||
$this->assertEquals("ContentControllerTestPage_test", $response->getBody());
|
$this->assertEquals("ContentControllerTestPage_test", $response->getBody());
|
||||||
|
|
||||||
|
// Test that an action without a template will default to the index template, which is
|
||||||
|
// to say the default Page.ss template
|
||||||
|
$response = $this->get($page->RelativeLink("testwithouttemplate"));
|
||||||
|
$this->assertEquals("Foo", $response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -190,5 +195,10 @@ class ContentControllerTestPage extends Page { }
|
|||||||
class ContentControllerTestPage_Controller extends Page_Controller {
|
class ContentControllerTestPage_Controller extends Page_Controller {
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
"test",
|
"test",
|
||||||
|
"testwithouttemplate"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function testwithouttemplate() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user