Skip to content

Commit

Permalink
Ensure URL segment field type before using its API, and add docs arou…
Browse files Browse the repository at this point in the history
…nd subsite and fluent domain compatibility
  • Loading branch information
robbieaverill committed May 30, 2019
1 parent e313f2e commit 725284d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions docs/en/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ to speak to your website administrator or hosting provider to facilitate this.


You can simulate subsite access without setting up virtual hosts by appending ?SubsiteID=<ID> to the request.

### How do Subsite domains work with Fluent domains?

The Subsites module and Fluent translation module both provide the concept of defining "domains" and let you
configure the host name for it. This functionality is essentially performing the same duty in both modules.

In the "URL segment" field for CMS pages both Subsites and Fluent will add their context to the value. If you
have a Subsite domain configured but no Fluent domain, Fluent will respect the existing domain and add its
locale context to the value. If you have a Subsite domain configured and a Fluent domain configure, Fluent will
use its own domain host name value, and the Subsite domain value will be lost. For this reason, you will need
to ensure that you use the same host name in both Subsite and Fluent domain entries.
4 changes: 3 additions & 1 deletion src/Extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\Subsites\Extensions;

use Page;
use SilverStripe\CMS\Forms\SiteTreeURLSegmentField;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
Expand Down Expand Up @@ -150,6 +151,7 @@ public function updateCMSFields(FieldList $fields)
// replace readonly link prefix
$subsite = $this->owner->Subsite();
$nested_urls_enabled = Config::inst()->get(SiteTree::class, 'nested_urls');
/** @var Subsite $subsite */
if ($subsite && $subsite->exists()) {
// Use baseurl from domain
$baseLink = $subsite->absoluteBaseURL();
Expand All @@ -163,7 +165,7 @@ public function updateCMSFields(FieldList $fields)
}

$urlsegment = $fields->dataFieldByName('URLSegment');
if ($urlsegment) {
if ($urlsegment && $urlsegment instanceof SiteTreeURLSegmentField) {
$urlsegment->setURLPrefix($baseLink);
}
}
Expand Down

0 comments on commit 725284d

Please sign in to comment.