Reputation: 33
I am pretty new to laravel, basically I have 3 pages home
, contact
and people
. All my app layout are in app.blade.php
and the problem I am facing is on the home.blade.php
. It needs to contains contact and people page but it's not working.
Here is what I have tried:
My app.blade.php
looks similar to:
</header>
<body>
@yield("content")
</body>
<footer>
contact.blade.php
:
@extends('app')
@section('content')
//contact
@stop
people.blade.php
:
@extends('app')
@section('content')
//people
@stop
Now here I am confused.
home.blade.php
@extends('app')
@section('content')
//home
@include('people')
@include('contact')
@stop
When I use include
here people
pages shows up but contact
doesn't, and when I use yield
nothing shows up. How should I build this page so both people
and contact
pages gets included as one page?
Upvotes: 2
Views: 4472
Reputation: 5078
One way to achive what you want is to have the content of 'people' and 'contact' in other view. Then you will can include them in main 'people' and 'contact' views, and in any other view:
app.blade.php
..
</header>
<body>
@yield("content")
</body>
<footer>
..
contact.blade.php
@section('content')
@include('contact-content')
@stop
contact-content.blade.php
//contact
people.blade.php
@section('content')
@include('people-content')
@stop
people-content.blade.php
//people
home.blade.php
@extends('app')
@section('content')
//home
@include('people-content')
@include('contact-content')
@stop
Upvotes: 2
Reputation: 111
Don't use @extends in your other pages like people and contact the reason is that you already using @extends app In your home.blade.php so you will automatically get the header and footer in both the pages people and contact
Upvotes: 0