mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
This commit is contained in:
parent
0b3b4b555c
commit
52bd509219
@ -15,6 +15,7 @@ Object::add_extension('LeftAndMain', 'ControllerSubsites');
|
||||
Object::add_extension('Group', 'GroupSubsites');
|
||||
Object::add_extension('Member', 'MemberSubsites');
|
||||
Object::add_extension('File', 'FileSubsites');
|
||||
Object::add_extension('ErrorPage', 'ErrorPageSubsite');
|
||||
|
||||
// Backwards compatibility with SilverStripe 2.2
|
||||
if(!class_exists('CMSMenu')) {
|
||||
|
30
code/ErrorPageSubsite.php
Normal file
30
code/ErrorPageSubsite.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
class ErrorPageSubsite extends DataObjectDecorator {
|
||||
|
||||
/**
|
||||
* Alter file path to generated a static (static) error page file to handle error page template on different sub-sites
|
||||
*
|
||||
* @see Error::get_filepath_for_errorcode()
|
||||
*
|
||||
* FIXME since {@link Subsite::currentSubsite()} partly relies on Session, viewing other sub-site (including main site) between
|
||||
* opening ErrorPage in the CMS and publish ErrorPage causes static error page to get generated incorrectly.
|
||||
*/
|
||||
function alternateFilepathForErrorcode($statusCode, $locale = null) {
|
||||
$static_filepath = Object::get_static($this->owner->ClassName, 'static_filepath');
|
||||
$subdomainPart = "";
|
||||
|
||||
if($subsite = Subsite::currentSubsite(false)) {
|
||||
$subdomain = $subsite->Subdomain;
|
||||
$subdomainPart = "-{$subdomain}";
|
||||
}
|
||||
|
||||
if(singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_locale()) {
|
||||
$filepath = $static_filepath . "/error-{$statusCode}-{$locale}{$subdomainPart}.html";
|
||||
} else {
|
||||
$filepath = $static_filepath . "/error-{$statusCode}{$subdomainPart}.html";
|
||||
}
|
||||
|
||||
return $filepath;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user