That's a very open ended question...
You could checkout Cartalyst who make a Theme package. You could look at overriding Laravel's view finder or you could search for a "Laravel theme package", of which there are several.
The best way is to create a method in your BaseController called MakeView and controller return $-this->makeView ('ViewName'); and there you decide which theme to use, you can put your themes in different folders.
***Here is an example: *BaseController
class BaseController extends Controller {
private $theme;
public function __construct() {
$this->theme = Session::get('theme');
}
protected function setupLayout() {
if (!is_null($this->layout)) {
$this->layout = View::make($this->layout);
}
}
protected function makeView($viewname, $data=array()) {
return View::make($this->theme.'.'.$viewname, $data);
}
}
You can checkout this links too :
If you are working with Laravel 5 you can try igaster/laravel-theme
Features:
Hi I am new in laravel for last 1 week. I have an assignment to develop an web application in which user select theme which he/she like. I have two different theme in laravel application now i want to switch one theme to another theme during runtime. I waste two days for this small task and i tried lot of thing like laravel/igastertheme package of you and follow it step by step but could not found success and i do not find any video link or tutorial to managing multiple theme in an application. I see you(igaster) in different threads or your package name. I request you please made a video how to use your package, add multiple themes and switch between these theme during run time its help me and beginner like me. i am very grateful to you.
thanks for reply but i need to change entire theme folder not a single view and each theme have its on css if is switch theme during runtime then i access the css/js or assets fill automatically :-( like:
so the view files are also changed ?
change where to load views from in your app service provider, example
public function boot()
{
$themeName = 'theme1';
$this->loadViewsFrom([realpath(__DIR__ . '/../resources/themes/'.$themeName.'/views')]');
}
probably you want to create a service provider that will take care of this.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community