Answer the question
In order to leave comments, you need to log in
How to properly share data via @section, @yield in blade?
I have main layouts,app :
<head>
<meta charset="utf-8">
</head>
<body>
@yield('news')
@yield('other_news')
</body>
</html>
@extends('layouts.app')
@section('news')
тут вывод новости
@endsection
@extends('layouts.app')
@section('news')
Другие новости
@endsection
Answer the question
In order to leave comments, you need to log in
Thanks for the help @den-masonov
This is what the templates should look like:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
@yield('content')
@yield('comment')
@yield('news')
</body>
</html>
@extends('layouts.app')
@section('content')
{{ $content = 'Контент' }} <br>
@endsection
@section('comment')
{{ $comment = 'Коммент' }} <br>
@endsection
@section('news')
{{ $news = 'Новости' }} <br>
@endsection
@extends('news.index')
@section('content')
{{ $news = 'Вложенные новости' }} <br><br>
@endsection
Multiple sections can be displayed
@extends('layouts.app')
@section('news')
Другие новости
@endsection
@section('other_news')
Ещё новости
@endsection
In the body you are displaying a cell of content that will be available to all pages. You do not need to add labels for all pages
. To access other_news, do the same as with news, but you should not do this. Usually this cell is called content and is used for all pages
@extends('layouts.app')
@section('news')
Новости
@endsection
@section('other_news')
Другие новости
@endsection
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question