From 45d8a86a19a66f7612d3e61413f9c15262e754c8 Mon Sep 17 00:00:00 2001 From: filesite Date: Sat, 23 Apr 2022 05:25:42 +0800 Subject: [PATCH] double slashes // support --- controller/Controller.php | 12 ++++++++++++ views/layout/main.php | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/controller/Controller.php b/controller/Controller.php index 9abdf87..b7e635b 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -25,8 +25,20 @@ Class Controller { //render view protected function render($viewName, $viewData = array(), $pageTitle = '') { $layoutFile = __DIR__ . '/../views/layout/' . $this->layout . '.php'; + $viewFile = __DIR__ . '/../views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; + //双斜杠//开头的共享视图支持 + if (preg_match('/^\/\//', $viewName)) { + $viewFile = __DIR__ . '/../views/' . str_replace('//', '/', $viewName) . '.php'; + } + if (!empty(FSC::$app['config']['theme'])) { $layoutFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/layout/' . $this->layout . '.php'; + $viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; + //双斜杠//开头的共享视图支持 + if (preg_match('/^\/\//', $viewName)) { + $viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . + str_replace('//', '/', $viewName) . '.php'; + } } //include layout and view diff --git a/views/layout/main.php b/views/layout/main.php index 84bd2ad..2824a56 100644 --- a/views/layout/main.php +++ b/views/layout/main.php @@ -12,8 +12,9 @@