php - How to use a layout statically in Laravel? -


as admin can create pages (don't think have paste adminpagescontroller here, because understand logic). i'm getting stuck on, selecting, using layout used page.

i.e. have 3 layouts:

  • page left sidebar
  • page right sidebar
  • page full-width (no sidebars)

and i.e. want create salespage or so, uses layouts "page full-width". how can call in view?

now views begin @extends('layouts.path.file') <--- need filled in database, if know mean.

one way of doing use view composer define current layout used. view composers set variables can used views ('*') or ('users.profile', 'admin.profile'), example of using user specific layout:

view::composer('*', function($view) {     $view->with('userlayout', auth::check() ? auth::user()->layout : 'main'); }); 

and in view have to:

@extends('layouts.'.$userlayout); 

if need select page on controller, can pass layout it:

return view::make('myview')->with('layout', 'front.main'); 

and use in view:

@extends('layouts.'.$layout); 

and if have on table, can pass on:

$layout = pages::first()->layout;  return view::make('myview')->with('layout', $layout); 

or same in composer

view::composer('*', function($view) {     $layout = pages::first()->layout;      $view->with('layout', $layout); }); 

a lot of people set layout in controller too, in controller do:

public function showprofile() {     $this->layout = pages::first()->layout;      $this->layout->content = view::make('user.profile'); } 

and views doesn't have @extend layout anymore, because telling them layout use.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -