A
A
Apostol632021-11-23 12:20:49
Laravel
Apostol63, 2021-11-23 12:20:49

How to connect 2 views into one layout in laravel?

Good day everyone

I started tinkering with laravel and its blade templating engine. The following question arose
How to connect 2 different views to one layout?

In both views I use @extend

Here is the layout

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>App Name</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/[email protected]/dist/vuex.js"></script>
{{--    <link rel="stylesheet" href={{ URL::asset('css/custom.css') }}>--}}

</head>
<body>
@yield('contentTwo')
    <section class="content">
        <div class="wraper container-fluid">
            @yield('content')
        </div>
    </section>
</body>
<script src={{ asset('js/app.js') }}></script>
</html>


Here is the first view
@extends('layouts.home')

@section('content')
    ssssss
@endsection


Here is the second view
@extends('layouts.home')

@section('contentTwo')
    sss223231
@endsection


Layout
name home.blade.php 1st view name home.blade.php
2nd view name file.blade.php

Display only view content home.blade.php
File is ignored.

I suspect that the file name plays a role, but then how can I make a separate view called header.blade and use it everywhere?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-11-23
@Apostol63

One twist. It can have any number of sections. If there are any in the parent templates, they will be displayed.

@extends('layouts.home')

@section('content')
    ssssss
@endsection

@section('contentTwo')
    sss223231
@endsection

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question