Skip to content

Commit

Permalink
Set template fallback
Browse files Browse the repository at this point in the history
Important if a template name specified exists in Layout folder only
  • Loading branch information
jonom committed Jul 12, 2018
1 parent 451cba9 commit 9115403
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/CustomErrorControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public function customError($errorCode, $customFields, $template = null, $contro

// Otherwise build a themed response
if (!$controllerType) $controllerType = $this->config()->get('default_controller');
if (!$template) $template = $this->config()->get('default_template');
$templates = [];
if ($template) $templates[] = $template;
// Fallback to default template
$templates[] = $this->config()->get('default_template');
$templates[] = 'Page';
$defaultCustomFields = $this->defaultCustomFieldsFor($errorCode);
$response = new HTTPResponse();
$response->setStatusCode($errorCode);
Expand All @@ -102,7 +106,7 @@ public function customError($errorCode, $customFields, $template = null, $contro
$controller->setResponse(new HTTPResponse());
$controller->doInit();
$controller->pushCurrent();
$body = $controller->renderWith($template, $customFields);
$body = $controller->renderWith($templates, $customFields);
$controller->popCurrent();
$response->setBody($body);
if ($response) {
Expand Down

0 comments on commit 9115403

Please sign in to comment.