2015-10-14 30 views
2

我試圖在我的網站中使用彈出窗口。我注意到的是,如果您在頁面上多次擴展模板,收益最終會被最後一個重寫。任何幫助?在同一頁面laravel中擴展兩次相同的佈局5.1

<!-- layout.blade.php --> 
@yield('section1') 
div div div 
@yield('section2') 

<!-- popup1.blade.php --> 
@extends('layout') 
@section('section1') 
    <p>here's some content about cats</p> 
@stop 
@section2('section2') 
    <p>bla bla bla </p> 
@stop 

<!-- popup2.blade.php --> 
@extends('layout') 
@section('section1') 
    <p>here's some content about monkeys</p> 
@stop 
@section('section2') 
    <p> bla bla bla </p> 
@stop 

回答

1

那麼,我自己找到了同樣的解決方案。如果有人遇到同樣的問題。這裏是解決方案

用@overwrite結束每個部分,它將解決問題。

<!-- layout.blade.php --> 
@yield('section1') 
div div div 
@yield('section2') 

<!-- popup1.blade.php --> 
@extends('layout') 
@section('section1') 
    <p>here's some content about cats</p> 
@overwrite 
@section2('section2') 
    <p>bla bla bla </p> 
@overwrite 

<!-- popup2.blade.php --> 
@extends('layout') 
@section('section1') 
    <p>here's some content about monkeys</p> 
@overwrite 
@section('section2') 
    <p> bla bla bla </p> 
@overwrite 
+0

這個鏈接有點幫助一個很好:http://laravel-recipes.com/recipes/244/stopping-injecting-content-into-a-section-and-overwriting – 2017-08-30 14:18:41

相關問題