Reputation: 9065
I would like apply on a laravel 5.4 project some basic theme switching ability.
I made under config folder a site.php config file where I added the following
return [
'theme' => realpath(base_path('my_theme/views'))
];
than in controller I call it like
Config::get('site.theme')
but when I try to pass to my controller I get View not found
however the showed path is correct
How do I implement in case of laravel some basic theming functionality?
I got it between
config/views.php
'paths' => [
//resource_path('views'),
realpath(base_path('themes/my_theme/views'))
],
but still interested how would I apply a multi theme templating system in case of laravel
Upvotes: 0
Views: 770
Reputation:
You probably want to use the theme as a layout. See the documentation here: https://laravel.com/docs/5.4/blade#defining-a-layout
This will allow you to build out a structured layout and then in your application you can switch which one you want to use between views. Typically all my views have an @extends('layouts.app')
directive at the top. You could easily replace 'layouts.app' with whatever value you store in a config and a user chooses.
Upvotes: 1