Support the ongoing development of Laravel.io →
Views Blade

What I want to do is

@include(@yield('layout'))

which I can't do because it is most likely nesting php tags inside one another. However I can't seem to find another solution where I can set something like

@section('layout') layouts.users @stop

for each page. This way I could have @extends('layouts.main') used for every file and use it for every page just changing a small section in the middle. This seems like a simple task I assume I am just approaching it wrong.

Thanks for any help on the matter.

Last updated 3 years ago.
0

I was thinking what I could do is load is extend something like @extends('layout.users') and include the information at the top but the OCD in me wants to leave extend the same for every file.

Last updated 3 years ago.
0

Ok so this is the solution that I thought of I extend a different page for each blade but the layout that is being called just contains.

@include( 'includes.default' )

Page

@include( 'includes.default_end' )

This lets me get around putting specific html in my footer and header files since I know that I will have 10% of my pages that need some different layout. Looking for some feedback still to see if others who have been using blade/laravel longer think this is a sane solution.

Last updated 3 years ago.
0
Solution

you can extend multiple sections and even overwriting them. there is also a @parent tag that allows you to append / prepend to the existing content.

aside from all this you can use variables

@extend( $MyVarThatWasSetInMyController )
Last updated 3 years ago.
0

zenry said:

you can extend multiple sections and even overwriting them. there is also a tag that allows you to append / prepend to the existing content.

aside from all this you can use variables

@extend( $MyVarThatWasSetInMyController )

Awesome, I was originally trying to stay away from in the page it should load through the controller. But that is what it is there for so... anyway I did what you said and I like it a lot more than my prior solution. Thanks for the help! Still getting use to blade and being able to use variables without php tags.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2025 Laravel.io - All rights reserved.