modules()->resolvePage($module, $page); if ($modulePage) { $target = $modulePage; } else { http_response_code(404); $target = $page404; } } elseif ($uriPath === '' || $uriPath === 'index' || $uriPath === 'index.php') { $target = $pagesBase . '/index.php'; } else { $base = $pagesBase . '/' . $uriPath; // 1) Verzeichnis mit index.php if (is_dir($base) && is_file($base . '/index.php')) { $target = $base . '/index.php'; } // 2) Datei elseif (is_file($base . '.php')) { $target = $base . '.php'; } // 3) 404 elseif (is_file($base)) { $target = $base; } // 3) 404 else { http_response_code(404); $target = $page404; } } // ------------------------------------ // Layout-Regel // ------------------------------------ $skipLayout = false; $targetReal = realpath($target); $retoolBase = realpath($pagesBase . '/retool/raw'); // Beispiel: alles unter landingpages/retool/* ohne Layout if ($targetReal && $retoolBase && str_starts_with($targetReal, $retoolBase)) { $skipLayout = true; } // ------------------------------------ // Ausgabe // ------------------------------------ // Erst Inhalt laden (ohne Ausgabe), damit Header/Redirects vor HTML funktionieren ob_start(); try { require $target; $content = ob_get_clean(); } catch (\App\ModuleConfigException $e) { ob_end_clean(); http_response_code(412); $moduleName = $e->module(); $module = app()->modules()->get($moduleName); $title = $module['title'] ?? $moduleName; $setupUrl = '/modules/setup/' . rawurlencode($moduleName); $content = '
'; } // Wenn bereits Header gesendet wurden (z. B. eigener Redirect/Content-Type), Layout überspringen if (headers_sent()) { $skipLayout = true; } if (!$skipLayout) { tpl('layout_start', 'structure'); } echo $content; if (!$skipLayout) { tpl('layout_end', 'structure'); }