mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-28 20:29:15 +02:00
ENHANCEMENT Added Controller->render($params) as a shortcut for Controller->customise($params)->renderWith(array('MyTemplate','MySubTemplate')) - templates are auto-detected by Controller->getViewer() and Controller->getAction()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63652 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e1e2329c90
commit
d53bbb0df1
@ -249,6 +249,24 @@ class Controller extends RequestHandlingData {
|
||||
return new SSViewer($templates);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the current controller with the templates determined
|
||||
* by {@link getViewer()}.
|
||||
*
|
||||
* @param array $params Key-value array for custom template variables (Optional)
|
||||
* @return string Parsed template content
|
||||
*/
|
||||
function render($params = null) {
|
||||
$template = $this->getViewer($this->getAction());
|
||||
|
||||
// if the object is already customised (e.g. through Controller->run()), use it
|
||||
$obj = ($this->customisedObj) ? $this->customisedObj : $this;
|
||||
|
||||
if($params) $obj = $this->customise($params);
|
||||
|
||||
return $template->process($obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to disable basic authentication on test sites.
|
||||
* must be called in the init() method
|
||||
|
Loading…
Reference in New Issue
Block a user