Shipu / themevel

Theme and asset management for laravel
Creative Commons Zero v1.0 Universal
347 stars 67 forks source link

Is it support layout switching. #4

Closed sohelrana820 closed 7 years ago

sohelrana820 commented 7 years ago

Suppose, one theme has 2/3 deferent layouts (app_ayout.blead.php, profile_layout_blade.php etc). And want to switch layout on runtime. Is there anything there. Just similar like CakePHP (https://book.cakephp.org/3.0/en/views.html)

Shipu commented 7 years ago

Yes possible. In your view you can pass a variable with the view name like

@extends($view)

here $view is a variable which stored the view name from controller my controller looks following

$view = 'profile_layout';
return view('someview', compact('view'));

It's applicable for current theme.

If you want to specific theme layout then:

$view = 'your_theme_name::profile_layout';
return view('someview', compact('view'));
sohelrana820 commented 7 years ago

OK, I understand. But there suppose to need to pass layout_name from every controller to view. Do you think it would be easier to use?

Shipu commented 7 years ago

Use view composer.