From 3491bb7a46a6f7f85b890056a2837a19bddc5839 Mon Sep 17 00:00:00 2001 From: Charles N Wyble Date: Mon, 2 Mar 2026 16:19:14 -0500 Subject: [PATCH] fix: working multi-site setup with minimal stream override MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- setup.php | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/setup.php b/setup.php index 2d91aa6..566f93e 100644 --- a/setup.php +++ b/setup.php @@ -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'], + ], + ], + ], + ], +];