Support the ongoing development of →
Views Blade
Last updated 2 years ago.

With Laravel is really easy to have your master template files organized. Lets say you want all your template files under one folder called '/layouts' and this folder contains your master template file, lets call it 'default.blade.php', then you create a page for your homepage called 'home.blade.php' (This file can be under the root of the view folder or it can be organized into its own subfolder) all you have to have to do is tell Laravel where the file is located and what is called. To do this you specify the folder under which your template is located, followed by the '.' delimiter (Pretty much '/') followed by the name of your file. In this case, from home.blade.php we would extend 'layouts/default.blade.php' by writting the following code:

// app/views/home.blade.php

Hope this helps. If this doesn't answers your question let me know!

Last updated 2 years ago.

Writing from a mobile, so can't give you full written examples, but surely someone can write it if it's not too clear.

Wanted to expand on Gustav's reply.

I tend to add protected $layout = 'master.template'; to my Base controller. And then load the views in the controller as $this->layout->content = View::make('user.index'); instead of the standard used return.

This way you don't need to extend every single layout. Just:

    Hello World!

And it should work. Just change $this->layout in any of the controllers if it needs another master template next to the main (frontend - backend).

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.