Funny Frontend
Funny Frontend

Reputation: 3925

Inheritance with Laravel 5

I have a master_page.blade with global content for my html:

<!DOCTYPE html>
<html lang="es">
<head>
    @include('layout.head')
</head>
<body>
    @include('layout.header')


    @yield('master_content')

    @section('footer')
        @include('layout.footer')
    @show

    @include('layout.scripts')

    @yield('custom_scripts')

</body>
</html>

After, I have a layout in Bootstrap with 2-6 columns, this blade inherit of the master_blade, his name is 2_10_columns.blade:

@extends('layout.master_page')

@section('master_content')
<div class="container">
    <div class="main-content">
        <div class="col-sm-2">
            @section('content1')
            @show
        </div>

        <div class="col-sm-10">     
            @section('content2')
            @show

        </div>
    </div>
</div>
@stop

Ok, this looks good but, finally I need fill the 2_10_columns.blade with some content, for example I tried this with mi contact.blade.php:

@extends('layout.2_10_columns')

@section('content1')
    <p>Column 2 left content of my section...</p>
@stop

@section('content2')
    <p>Column 10 right content of my section ...</p>
    ...some forms here
@stop

Definitely this does not work...

How could I do this with Laravel? Look at this infographic: enter image description here

Upvotes: 2

Views: 216

Answers (1)

Amir Bar
Amir Bar

Reputation: 3105

its working like this(simplified for example):

master layout:

<html>
<body>
 <div class="container">
   @yield('master_content')
 </div>
</body>
</html>

2 cols layout:

@extends('layouts.master')

@section('master_content')
 <div class="co-l2">
   <p>index</p>
   @yield('sidebar')
 </div>
 <div class="col-10">
   @yield('content')
 </div>
@endsection

contact view:

@extends('layouts.2cols')

@section('sidebar')
  <p>delete</p>
@endsection

@section('content')
   <h1> person name </h1>
   <p>about the person</p>
@endsection

Upvotes: 1

Related Questions