Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Basic SilverStripe 3.0 Framework Bootstrap
---
Name: app
After: framework/routes#coreroutes
---
Director:
rules:
'dev': 'DevelopmentAdmin'
'sitemap.xml': 'GoogleSitemap'
'$Action' : 'BaseController'
<?php
class BaseController extends Controller {
public static $allowed_actions = array(
'index'
);
/**
* Handle 404 errors gracefully as the normal 404 error pages are part
* of the CMS module
*/
public function handleAction($request) {
try {
$response = parent::handleAction($request);
return $response;
}
catch(SS_HTTPResponse_Exception $e) {
$response = $e->getResponse();
$response->addHeader('Content-Type', 'text/html; charset=utf-8');
$response->setBody($this->renderWith(array('Error', 'BaseController')));
return $response;
}
}
/**
* Return a HTTP error to the user
*/
public function httpError($errorCode = '404', $errorMessage = null) {
$this->response->setStatusCode($errorCode);
return $this->customise(new ArrayData(array(
'Title' => 'Whoops!',
'Content' => DBField::create_field('HTMLText', $errorMessage)
)))->renderWith(array(
'Error',
'BaseController'
));
}
/**
* Home action
*
* @return html
*/
public function index() {
return $this->customise(new ArrayData(array(
'Title' => 'Home',
)))->renderWith(array(
'Home'
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.