fix: working multi-site setup with minimal stream override
- Use minimal setup.php that only overrides 'page' stream - Override only page stream to avoid conflicts with Grav core streams - Environment-specific pages now load correctly per hostname - Remove unused add-streams.sh script Root cause: Grav's core streams (data, config, etc.) cannot be overridden in setup.php without causing initialization errors. The solution is to only override the 'page' stream, which allows each environment to have its own pages while sharing plugins, themes, and data with the main installation. Testing confirmed: - charters.turnsys.com → "TSYS Group Charters" - plan.knownelement.com → "Known Element Business Plan" - plan.startinglineproductions.com → "Starting Line Productions Plan" 🤖 Generated with [Crush](https://crush.cbhops.com) Assisted-by: GLM-5 via Crush <crush@charm.land>
This commit is contained in:
33
setup.php
33
setup.php
@@ -2,17 +2,13 @@
|
|||||||
/**
|
/**
|
||||||
* Grav Multi-Site Setup Configuration
|
* Grav Multi-Site Setup Configuration
|
||||||
* Maps hostnames to environment-specific directories
|
* Maps hostnames to environment-specific directories
|
||||||
*
|
* Only overrides 'page' stream to serve environment-specific content
|
||||||
* Uses Grav's native environment-based multi-site feature.
|
|
||||||
* The environment is determined by hostname.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Get the hostname from request
|
|
||||||
$hostname = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
|
$hostname = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
|
||||||
$hostname = preg_replace('/:\d+$/', '', $hostname);
|
$hostname = preg_replace('/:\d+$/', '', $hostname);
|
||||||
$hostname = strtolower($hostname);
|
$hostname = strtolower($hostname);
|
||||||
|
|
||||||
// Define supported hostnames
|
|
||||||
$hostMap = [
|
$hostMap = [
|
||||||
'charters.turnsys.com' => 'charters.turnsys.com',
|
'charters.turnsys.com' => 'charters.turnsys.com',
|
||||||
'plan.afabn.org' => 'plan.afabn.org',
|
'plan.afabn.org' => 'plan.afabn.org',
|
||||||
@@ -38,22 +34,23 @@ $hostMap = [
|
|||||||
'staticsites.turnsys.com' => 'staticsites.turnsys.com',
|
'staticsites.turnsys.com' => 'staticsites.turnsys.com',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Determine environment name (falls back to staticsites.turnsys.com)
|
|
||||||
$environment = isset($hostMap[$hostname]) ? $hostMap[$hostname] : 'staticsites.turnsys.com';
|
$environment = isset($hostMap[$hostname]) ? $hostMap[$hostname] : 'staticsites.turnsys.com';
|
||||||
$envPath = GRAV_ROOT . '/user/env/' . $environment;
|
$envPath = GRAV_ROOT . '/user/env/' . $environment;
|
||||||
|
|
||||||
// If environment directory doesn't exist, use default
|
|
||||||
if (!is_dir($envPath)) {
|
if (!is_dir($envPath)) {
|
||||||
$environment = 'staticsites.turnsys.com';
|
$envPath = GRAV_ROOT . '/user/env/staticsites.turnsys.com';
|
||||||
$envPath = GRAV_ROOT . '/user/env/' . $environment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the Grav environment - this tells Grav to look for config in user/env/{environment}/
|
// Only override page stream - use environment pages, fallback to default
|
||||||
// Grav will automatically handle stream prefixes based on this
|
return [
|
||||||
if (!defined('GRAV_ENVIRONMENT')) {
|
'streams' => [
|
||||||
define('GRAV_ENVIRONMENT', $environment);
|
'schemes' => [
|
||||||
}
|
'page' => [
|
||||||
|
'type' => 'ReadOnlyStream',
|
||||||
// Return empty array - Grav's native environment handling will take over
|
'prefixes' => [
|
||||||
// based on the GRAV_ENVIRONMENT constant
|
'' => [$envPath . '/pages', 'user://pages'],
|
||||||
return [];
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user