Support the ongoing development of Laravel.io →
posted 9 years ago
Blade
Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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);
    }

}
Last updated 1 year ago.
0

If you are working with Laravel 5 you can try igaster/laravel-theme

Features:

  • Views & Asset seperation in theme folders
  • Theme inheritence: Extend any theme and create Theme hierarcies & more...
0

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.

0

all you need to do is change the css file that is being included ?

0

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:

Last updated 7 years ago.
0

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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

akinsayo akinsayo Joined 28 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.