I have a site that is using a 'fake' multi-site instance (I think, someone else implemented it). We created 3 directories in sites
:
sites/site1
sites/site2
sites/site3
and in each settings.php
inside these directories it includes the original settings.php
from the default directory.
I am overriding the theme successfully in these files by doing $config['system.theme']['default'] = 'theme2';
When I try doing $config['system.site']['page']['front'] = '/node/239';
it works only on cache flush.
For example if I am on site 1 I see the front page set in the UI.
Then when I switch to site2.example.test
I still see the default front page instead of what is on /node/239
.
When I flush the cache, the reverse happens; site 2 homepage shows /node/239
and so does site 1.
I have also tried setting this in an event listener:
public function kernel_request(Event $event) {
$config = \Drupal::configFactory()->getEditable('system.site');
$site_path = \Drupal::service('site.path');
$site_path = explode('/', $site_path);
$site_name = $site_path[1];
if ($site_name === 'site2' && $event->getRequest()->getPathInfo() == '/') {
$config->set('page.front', '/node/239')->save();
}
else {
$config->set('page.front', '/home-content')->save();
}
}
This now does the right thing, but only after loading the page and then refreshing.
Could anyone tell me what the "correct" way of doing this would be that wont be cached?