Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Correcting a minor issue when determining a page not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Glasl committed Jan 27, 2016
1 parent f2cfd92 commit 7f91fee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [mediawesome](https://packagist.org/packages/nglasl/silverstripe-mediawesome)

_The current release is **1.1.8**_
_The current release is **1.1.9**_

A module for SilverStripe which will allow creation of dynamic media holders/pages
with CMS customisable types and attributes (blogs, events, news, publications).
Expand Down
39 changes: 39 additions & 0 deletions code/pages/MediaHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,45 @@ public function index() {
return $this->renderWith($templates);
}

/**
* Display an error page on invalid request.
*
* @parameter <{ERROR_CODE}> integer
* @parameter <{ERROR_MESSAGE}> string
*/

public function httpError($code, $message = null) {

// Determine the error page for the given status code.

$errorPages = ErrorPage::get()->filter('ErrorCode', $code);

// Allow extension customisation.

$this->extend('updateErrorPages', $errorPages);

// Retrieve the error page response.

if($errorPage = $errorPages->first()) {
Requirements::clear();
Requirements::clear_combined_files();
$response = ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
throw new SS_HTTPResponse_Exception($response, $code);
}

// Retrieve the cached error page response.

else if(file_exists($cachedPage = ErrorPage::get_filepath_for_errorcode($code, class_exists('Translatable') ? Translatable::get_current_locale() : null))) {
$response = new SS_HTTPResponse();
$response->setStatusCode($code);
$response->setBody(file_get_contents($cachedPage));
throw new SS_HTTPResponse_Exception($response, $code);
}
else {
return parent::httpError($code, $message);
}
}

/**
* Retrieve a paginated list of media holder/page children for your template, with optional date/tag filters parsed from the GET request.
*
Expand Down

0 comments on commit 7f91fee

Please sign in to comment.