igaster / laravel-theme

Theme support for Laravel
MIT License
516 stars 110 forks source link

Feature request #26

Closed UnrulyNatives closed 8 years ago

UnrulyNatives commented 8 years ago

Hi,

consider this case: I have a so-so interface in my app (root theme), I am slowly experimenting with a new layout (different CSS framework, etc) in a newly defined theme.

I would like to give my user a choice to peek into the new theme FOR A SINGLE VIEW would that be possible to ask Laravel 5.2 to load files from new theme WITHOUT permanently switching to the new theme?

Sth. like if($user_preview_new_theme != '1') { Theme::set_for_this_request('theme-name'); } return View::make('routines.index', compact('title','object')) ->with('itemkind', 'routines') ->with('task', 'view');

igaster commented 8 years ago

Sure! This is how Theme::set() works anyway. If you think about it you actually set the Theme in every single request (whether you store in session/database and load it in next requests is up to you!)

Have you tried to replace Theme::set_for_this_request with Theme::set() in your code? (I suppose that it is placed in your controller)

UnrulyNatives commented 8 years ago

Hi. Your solution works perfectly! Thank you!