diff --git a/config/system.php b/config/system.php index 0bc9192b40..95f4c797ff 100644 --- a/config/system.php +++ b/config/system.php @@ -194,4 +194,15 @@ 'fake_sql_queries' => config('app.debug'), + /* + |-------------------------------------------------------------------------- + | Layout + |-------------------------------------------------------------------------- + | + | Define the default layout that will be used by views. + | + */ + + 'layout' => env('STATAMIC_LAYOUT', 'layout'), + ]; diff --git a/src/Entries/Collection.php b/src/Entries/Collection.php index 7836916ad9..8c89afe4be 100644 --- a/src/Entries/Collection.php +++ b/src/Entries/Collection.php @@ -442,7 +442,7 @@ public function layout($layout = null) return $this ->fluentlyGetOrSet('layout') ->getter(function ($layout) { - return $layout ?? 'layout'; + return $layout ?? config('statamic.system.layout', 'layout'); }) ->args(func_get_args()); } diff --git a/src/Http/Controllers/FrontendController.php b/src/Http/Controllers/FrontendController.php index e315b0ef58..e6c22aeba3 100644 --- a/src/Http/Controllers/FrontendController.php +++ b/src/Http/Controllers/FrontendController.php @@ -45,7 +45,7 @@ public function route(Request $request, ...$args) $view = app(View::class) ->template($view) - ->layout(Arr::get($data, 'layout', 'layout')) + ->layout(Arr::get($data, 'layout', config('statamic.system.layout', 'layout'))) ->with($data) ->cascadeContent($this->getLoadedRouteItem($data)); diff --git a/src/Taxonomies/Taxonomy.php b/src/Taxonomies/Taxonomy.php index 8c61204c02..2e5010a9c9 100644 --- a/src/Taxonomies/Taxonomy.php +++ b/src/Taxonomies/Taxonomy.php @@ -436,7 +436,7 @@ public function layout($layout = null) return $this ->fluentlyGetOrSet('layout') ->getter(function ($layout) { - return $layout ?? 'layout'; + return $layout ?? config('statamic.system.layout', 'layout'); }) ->args(func_get_args()); } diff --git a/tests/Routing/RoutesTest.php b/tests/Routing/RoutesTest.php index 0da68d8226..ba2d5a137b 100644 --- a/tests/Routing/RoutesTest.php +++ b/tests/Routing/RoutesTest.php @@ -341,4 +341,16 @@ public function it_loads_term_by_binding() $this->get('/bindings/term/title/Blog2') ->assertNotFound(); } + + #[Test] + public function it_uses_a_non_default_layout() + { + config()->set('statamic.system.layout', 'custom-layout'); + $this->viewShouldReturnRaw('custom-layout', 'Custom layout {{ template_content }}'); + $this->viewShouldReturnRaw('test', 'Hello {{ hello }}'); + + $this->get('/basic-route-with-data') + ->assertOk() + ->assertSee('Custom layout'); + } }