Exclude a view from master layout?

2019-01-29 13:01发布

问题:

I have login.blade.php in views/users/ that I would like to exclude from the master layout that I have.

Instead I want the login page to be a standalone page with just the login form on it.

How may I achieve that?

回答1:

Use a different layout for login page:

File app/views/login.blade.php:

@extends('layouts.standalone')

@section('content')
   ...
@stop

And for your other pages:

File app/views/home.blade.php:

@extends('layouts.master')

@section('content')
   ...
@stop

And here your layouts:

File app/views/layouts/standalone.blade.php:

<html>
   <body>
      This is a master layout

      @yield('content')
   </body> 
</html>

File app/views/layouts/master.blade.php:

<html>
   <body>
      This is a standalone layout

      @yield('content')
   </body> 
</html>