Reputation:
I am trying to make layout using blade but the problem is that when i tried to @yield on the file which is included in master file but @yield is not working.
resouces/views/layouts/app.blade.php
<html>
<head>
...
...
</head>
<body>
@include('layouts.navigation')
@include('layouts.main_panel')
@include('layouts.footer')
</body>
</html>
resouces/views/layouts/main_panel.blade.php
// some html stuff
@yield('form')
// some html stuff
resouces/views/auth/login.blade.php
@extends('layouts.app')
@section('form')
<form>
// input
</form>
@endsection
Upvotes: 1
Views: 1481
Reputation: 1435
I would suggest you pass variables to the partials and echo them inside it. This is an alternative way to achieve what you are trying to do.
For example -
Partial blade file (resouces/views/partials.header.blade.php) -
<h4>{{ $name }}</h4>
View (resouces/views/custom.blade.php) -
@include('partials.header', [ 'name' => 'Lorem Ipsum' ])
Upvotes: 1
Reputation: 4248
I am also using laravel framework but i used to do in that way :-
Layout :- resouces/views/layouts/app.blade.php
<html>
<head>
...
...
</head>
<body>
@include('layouts.navigation')
@yield('content') // use @yield here why you need separate file
@include('layouts.footer')
</body>
</html>
After that :- resouces/views/auth/login.blade.php
@extends('layouts.app')
@section('content')
<form>
// input
</form>
@stop
Hope it helps!.. I used to follow this structure in laravel project
Upvotes: 0