Multisite support for Simple Sitemap in Drupal 8

Created on 9 August 2016, over 8 years ago
Updated 27 December 2023, 11 months ago

Environment:

Mysql 5.5.27
PHP 5.5.9
Drupal 8.1.7
Drush 8.1.2

Clean Drupal Install with the following enabled:

Domain
Domain Access
Domain Alias
Domain Configuration
Domain Content
Domain Source
Simple Sitemap

Domain setup:

example.com
site0.example.com
site1.example.com

Multisite sites (sites/sites.php):

$sites = array (
  'site0.example.com' => 'child_sites',
  'site1.example.com' => 'child_sites',
);

Multisite Database settings (sites/child_sites/settings.php):

$childSite = current(explode('.', $request->getHost()));

if (in_array($childSite, array('site0', 'site1'))) {
    // Good
} else {
    throw new NotFoundHttpException('Invalid child site');
}

$databases['default']['default'] = array(
      'database' => 'DATABASE',
      'username' => 'USERNAME',
      'password' => 'PASSWORD',
      'prefix' => 
      array (
        'default' => '',
        'simple_sitemap' => $childSite . '_',
      ),
      'host' => 'localhost',
      'port' => '3306',
      'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
      'driver' => 'mysql',
);

Database tables:

simple_sitemap
site0_simple_sitemap
site1_simple_sitemap

Support Issue:

Requests to /sitemap.xml the last generated sitemap for all sites, not the sitemap generated for the host. The data in the table for each site is correct.

Possible workarounds:

  1. Turn off page caching for /sitemap.xml
✨ Feature request
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Yzmir Ramirez

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024