jeudi 4 mai 2017

Repeat extended blade script multiple times with different content - Laravel

How can I make use of default-content.blade.php mutliple times in page.blade.php without overriding the set content? Also app.blade.php is the main file leading the content.

I have the following 3 files:

app.blade.php - Main file

@yield('content')

default-content.blade.php - The file that is needs to be included mutliple times in page.blade.php

@section('content')
    <div id="@yield('default-content-id')" class="col-xs-12 default-content-wrapper">
        @yield('default-content-header')
        <div class="default-content col-xs-10 col-xs-push-1">
            @yield('default-content')
        </div>
    </div>
@append

page.blade.php - This file that extends app and default-content

@extends('app')

@extends('default-content')
    @section('default-content-id','some-random-id')
    @section('default-content-header')
        <div class="col-xs-10 col-xs-push-1">
            <h6 class="col-xs-12">Some Header...</h6>
        </div>
    @endsection

    @section('default-content')
        <p class="col-xs-12">
           Some Content #1...
        </p>
    @endsection

// Above section needs to be used again but with different values for 
   yield... [default-content-id, default-content-header, default-content]



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2pbN0c7
via IFTTT

Aucun commentaire:

Enregistrer un commentaire