سؤال

I'm really confused. that's about several hours that I trying to figure out the relationships of blade system.

However I yet haven't learned all of its points.

My Question is:

I have defined the master.blade.php which contains the following code:

<!doctype HTML>
<html>

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

But I do not know how should I define header and content in the following controller:

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

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

}
هل كانت مفيدة؟

المحلول

In constructor of BaseController:

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

In master.blade.php:

{{ $header }}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top