caffeinated / themes

:art: Laravel Themes package with support for the Caffeinated Modules package.

Home Page:https://caffeinatedpackages.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with dinamic call to setActive()

opened this issue · comments

I've created a great structure to choose and render my themes. Within a middleware, i call Theme::setActive() and Theme::setLayout(); based on the actual namespace.

It's working fine but i found something that looks like a bug:

After setting the default active theme and the default layout name through the middleware , i want to let some of my controller methods to be able to modify which theme to render. So i call Theme::setActive() again from my controller.

The problem is: only the active theme is being selected, but the name of the active layout is retrieving the old theme.

Example:
// Middleware
Theme::setActive('landing');
Theme::setLayout('layouts.default');

// Controller
Theme::setActive('other');

when i call $theme_layout from my view, i get "landing::layouts.default" instead of "other::layouts.default".
I know that i can call Theme::setLayout() again from my controller to resolve this, but i don't think this will be a good practice. Maybe is better if we can perform some changes to the method "getLayout()" of the "Theme" class, to check again for the active layout, before setting the $theme_layout.

commented

İ solved this problem.
i added the .env file.
ACTIVE_THEME=default_theme_name
http://laravel-tricks.com/tricks/change-the-env-dynamically