Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending a page that extends another in Laravel

welcome.blade.php:

@extends('layouts.app')
@section('content')
@yield('posts')
@endsection

posts.blade.php:

@extends('welcome')
@section('posts')
asfdsfdsf
@endsection

Both files are in the same folder outside of the layouts folder. What am i doing wrong?

like image 450
Daniel Sanchez Avatar asked Oct 21 '25 15:10

Daniel Sanchez


1 Answers

A lot of depends what you have in your app.blade.php. If you have:

@yield('content')

then you should have displayed asfdsfdsf without any problem.

EDIT

Full working example:

In controller:

return view('test.posts');

resources/views/test/posts.blade.php:

@extends('test.welcome')
@section('posts')
    asfdsfdsf
@stop

resources/views/test/welcome.blade.php

@extends('layouts.app')
@section('content')
    @yield('posts')
@stop

resources/views/layouts/app.blade.php

@yield('content')

Result is:

asfdsfdsf

as expected

like image 141
Marcin Nabiałek Avatar answered Oct 23 '25 06:10

Marcin Nabiałek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!