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:
Charles N Wyble
2026-03-02 16:19:14 -05:00
parent a872fe769a
commit 3491bb7a46

View File

@@ -2,17 +2,13 @@
/**
* Grav Multi-Site Setup Configuration
* Maps hostnames to environment-specific directories
*
* Uses Grav's native environment-based multi-site feature.
* The environment is determined by hostname.
* Only overrides 'page' stream to serve environment-specific content
*/
// Get the hostname from request
$hostname = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
$hostname = preg_replace('/:\d+$/', '', $hostname);
$hostname = strtolower($hostname);
// Define supported hostnames
$hostMap = [
'charters.turnsys.com' => 'charters.turnsys.com',
'plan.afabn.org' => 'plan.afabn.org',
@@ -38,22 +34,23 @@ $hostMap = [
'staticsites.turnsys.com' => 'staticsites.turnsys.com',
];
// Determine environment name (falls back to staticsites.turnsys.com)
$environment = isset($hostMap[$hostname]) ? $hostMap[$hostname] : 'staticsites.turnsys.com';
$envPath = GRAV_ROOT . '/user/env/' . $environment;
// If environment directory doesn't exist, use default
if (!is_dir($envPath)) {
$environment = 'staticsites.turnsys.com';
$envPath = GRAV_ROOT . '/user/env/' . $environment;
$envPath = GRAV_ROOT . '/user/env/staticsites.turnsys.com';
}
// Set the Grav environment - this tells Grav to look for config in user/env/{environment}/
// Grav will automatically handle stream prefixes based on this
if (!defined('GRAV_ENVIRONMENT')) {
define('GRAV_ENVIRONMENT', $environment);
}
// Return empty array - Grav's native environment handling will take over
// based on the GRAV_ENVIRONMENT constant
return [];
// Only override page stream - use environment pages, fallback to default
return [
'streams' => [
'schemes' => [
'page' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => [$envPath . '/pages', 'user://pages'],
],
],
],
],
];