【问题标题】:Laravel templating engine confusionLaravel 模板引擎混淆
【发布时间】:2014-02-12 11:53:09
【问题描述】:

我真的很困惑。这大约是我试图弄清楚刀片系统的关系的几个小时。

但是我还没有学会它的所有要点。

我的问题是:

我定义了master.blade.php,其中包含以下代码:

<!doctype HTML>
<html>

    <head>
        @section("header")
        @show
    </head>
    <body>
        @yield("content")
    </body>
    <footer>
        @section("footer")
    </footer>
</html>

但我不知道我应该如何在以下控制器中定义标题和内容:

class sample extends BaseController
{
    protected $layout = "layout.master";

    function show()
    {
        // the code which goes here
    }

}

【问题讨论】:

    标签: php templates laravel blade


    【解决方案1】:

    在 BaseController 的构造函数中:

    $this->layout->header = View::make('header');
    

    在master.blade.php中:

    {{ $header }}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-26
      • 1970-01-01
      • 2012-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多