【问题标题】:Sub template (or sub section) in Laravel 4Laravel 4 中的子模板(或子部分)
【发布时间】:2013-11-03 15:11:21
【问题描述】:

我不能扩展已经扩展了另一个布局的布局吗?

我想拥有

// layouts/default.blade.php
<html>
...
@yield('content')
...
</html>

在那之前一切都很好......

// users/myaccount.blade.php
@extends('layouts.default')

@section('content')
    @section('user-page')
        some default static content for the user page
    @stop
@stop

但是当我尝试用

修改user-page部分的内容时
// users/orders.blade.php
@extends('users.myaccount')

@section('user-page')
    content for messages page
@stop

没有交易。它呈现我帐户的内容,但不呈现订单的内容。 我像这样从 UserController 调用它

public function orders() {
    return View::make('users.orders');
}

我错过了什么?我可以只扩展一次布局吗?

提前致谢。

【问题讨论】:

    标签: laravel laravel-4 blade


    【解决方案1】:

    这个呢?

    layouts/default.blade.php

    <!DOCTYPE html>
    <html>
    <head>
        <title>App</title>
    </head>
    <body>
        @include('users.myaccount')
        @yield('content')
    </body>
    </html>
    

    users/myaccount.blade.php

    <p>some default static content for the user page</p>
    

    users/orders.blade.php

    @extends('layouts.default')
    
    @section('content')
        <p>content for messages page</p>
    @stop
    

    还有控制器功能,

    public function orders() {
        return View::make('users.orders');
    }
    

    【讨论】:

      猜你喜欢
      • 2013-12-11
      • 1970-01-01
      • 1970-01-01
      • 2014-02-06
      • 1970-01-01
      • 2013-07-19
      • 2013-08-27
      • 2023-03-08
      • 2014-04-04
      相关资源
      最近更新 更多