Reputation: 51
I have the following structure:
- master.blade {
@yield('menu') // here I load the one and only menu I have
@yield('content') // here I load different pages
}
- menu.blade {
@extends('master')
@section('menu')
main menu
@stop
}
- other pages using the same format {
@extends('master')
@section('content')
here is the content
@stop
}
For some reason the menu is not loaded. Any ideas why? I try to load the menu and then page. It's simple stuff, but for some reason I don't see why it's not working.
Upvotes: 1
Views: 2989
Reputation: 54389
use @include('menu')
instead of @yield('menu')
in master.blade
layout.
remove @extends
, @section('menu')
and @stop
from menu.blade
After these changes your code should look like:
master.blade
@include('menu')
@yield('content')
menu.blade
main menu
other pages
@extends('master')
@section('content')
here is the content
@stop
Read more about templates: http://laravel.com/docs/5.0/templates
btw, you can use @endsection
instead of @stop
, it's more readable as to me.
Upvotes: 2
Reputation: 653
The flow should be like this:
- master.blade {
@include('menu') // here I load the one and only menu I have
@yield('content') // here I load different pages
}
- menu.blade {
Markup for the main menu
}
- other pages using the same format {
@extends('master')
@section('content')
here is the content
@stop
}
Create simple menu file and include it in master template, yield is used for dynamic contents.
Upvotes: 1