mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
ENH added config setting to ignore subsite language (#481)
added config setting to ignore subsite language; when using subsites in combination with fluent it picked up wrong yml file
This commit is contained in:
parent
b16495cf54
commit
74b6cec374
@ -220,6 +220,14 @@ or by defining the subsiteCMSShowInMenu function in your admin:
|
||||
return true;
|
||||
}
|
||||
|
||||
### Using Subsites in combination with Fluent
|
||||
|
||||
When using Subsites in combination with Fluent module, the Subsites module sets the i18n locale to the language defined in the current Subsite. When this behaviour is not desired and you need to use the locale in FluentState use the following setting in your yml config file:
|
||||
|
||||
```yaml
|
||||
SilverStripe\Subsites\Extensions\SiteTreeSubsites:
|
||||
ignore_subsite_locale: true
|
||||
```
|
||||
|
||||
### Public display of a subsite
|
||||
|
||||
|
@ -398,7 +398,13 @@ class SiteTreeSubsites extends DataExtension
|
||||
SSViewer::set_themes(ThemeResolver::singleton()->getThemeList($subsite));
|
||||
}
|
||||
|
||||
if ($subsite && i18n::getData()->validate($subsite->Language)) {
|
||||
$ignore_subsite_locale = Config::inst()->get(self::class, 'ignore_subsite_locale');
|
||||
|
||||
if (!$ignore_subsite_locale
|
||||
&& $subsite
|
||||
&& $subsite->Language
|
||||
&& i18n::getData()->validate($subsite->Language)
|
||||
) {
|
||||
i18n::set_locale($subsite->Language);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ErrorPage\ErrorPage;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\Subsites\Extensions\SiteTreeSubsites;
|
||||
@ -191,6 +192,22 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
||||
$this->assertEquals($p2->ID, SiteTree::get_by_link('test-page')->ID);
|
||||
}
|
||||
|
||||
public function testIgnoreSubsiteLocale()
|
||||
{
|
||||
|
||||
$ignore_subsite_locale = Config::inst()->set(SiteTreeSubsites::class, 'ignore_subsite_locale', true);
|
||||
|
||||
$subsitePage = $this->objFromFixture(Page::class, 'subsite_locale_about');
|
||||
Subsite::changeSubsite($subsitePage->SubsiteID);
|
||||
$controller = ModelAsController::controller_for($subsitePage);
|
||||
|
||||
$i18n_locale_before = i18n::get_locale();
|
||||
SiteTree::singleton()->extend('contentcontrollerInit', $controller);
|
||||
$i18n_locale_after = i18n::get_locale();
|
||||
|
||||
$this->assertEquals($i18n_locale_before, $i18n_locale_after);
|
||||
}
|
||||
|
||||
public function testPageTypesBlacklistInClassDropdown()
|
||||
{
|
||||
$this->logInAs('editor');
|
||||
|
@ -360,7 +360,8 @@ class SubsiteTest extends BaseSubsiteTest
|
||||
['Title' => 'Test 3'],
|
||||
['Title' => 'Test Non-SSL'],
|
||||
['Title' => 'Test SSL'],
|
||||
['Title' => 'Test Vagrant VM on port 8080']
|
||||
['Title' => 'Test Vagrant VM on port 8080'],
|
||||
['Title' => 'Locale subsite'],
|
||||
], $subsites, 'Lists all subsites');
|
||||
}
|
||||
|
||||
@ -398,6 +399,7 @@ class SubsiteTest extends BaseSubsiteTest
|
||||
$adminSiteTitles = $adminSites->column('Title');
|
||||
sort($adminSiteTitles);
|
||||
$this->assertEquals([
|
||||
'Locale subsite',
|
||||
'Subsite1 Template',
|
||||
'Subsite2 Template',
|
||||
'Template',
|
||||
@ -417,7 +419,7 @@ class SubsiteTest extends BaseSubsiteTest
|
||||
);
|
||||
$member2SiteTitles = $member2Sites->column('Title');
|
||||
sort($member2SiteTitles);
|
||||
$this->assertEquals('Subsite1 Template', $member2SiteTitles[0], 'Member can get to subsite via a group role');
|
||||
$this->assertEquals('Subsite1 Template', $member2SiteTitles[1], 'Member can get to subsite via a group role');
|
||||
}
|
||||
|
||||
public function testhasMainSitePermission()
|
||||
|
@ -18,6 +18,10 @@ SilverStripe\Subsites\Model\Subsite:
|
||||
Title: 'Test Non-SSL'
|
||||
domaintestVagrant:
|
||||
Title: 'Test Vagrant VM on port 8080'
|
||||
subsitelocale:
|
||||
Title: 'Locale subsite'
|
||||
Language: 'nl_NL'
|
||||
|
||||
SilverStripe\Subsites\Model\SubsiteDomain:
|
||||
subsite1:
|
||||
SubsiteID: =>SilverStripe\Subsites\Model\Subsite.subsite1
|
||||
@ -27,6 +31,11 @@ SilverStripe\Subsites\Model\SubsiteDomain:
|
||||
SubsiteID: =>SilverStripe\Subsites\Model\Subsite.subsite2
|
||||
Domain: subsite2.*
|
||||
Protocol: automatic
|
||||
subsitelocale:
|
||||
SubsiteID: =>SilverStripe\Subsites\Model\Subsite.subsitelocale
|
||||
Domain: subsitelocale.*
|
||||
Protocol: automatic
|
||||
IsPrimary: 1
|
||||
dt1a:
|
||||
SubsiteID: =>SilverStripe\Subsites\Model\Subsite.domaintest1
|
||||
Domain: one.example.org
|
||||
@ -118,6 +127,10 @@ Page:
|
||||
Title: 'Contact Us (Subsite 2)'
|
||||
SubsiteID: =>SilverStripe\Subsites\Model\Subsite.subsite2
|
||||
URLSegment: contact-us
|
||||
subsite_locale_about:
|
||||
Title: 'About Locale'
|
||||
SubsiteID: =>SilverStripe\Subsites\Model\Subsite.subsitelocale
|
||||
URLSegment: about
|
||||
|
||||
SilverStripe\Security\PermissionRoleCode:
|
||||
roleCode1:
|
||||
|
Loading…
Reference in New Issue
Block a user