简体   繁体   中英

Layout is not including in the main file in Laravel

I've the main file which is welcome.blade.php where I've mark up something like this

<!DOCTYPE html>
    <html>
    <head>
        <title>
            @yield('title')    // title from signup.blade.php
        </title>
    </head>
    <body>

        <!-- some content here -->


         @yield('signup')    // I'm loading this from signup.blade.php



        <!-- some content here -->

    </body>
    </html>

I'm loading sign up page from signup.blade.php which is in directory layouts/signup.blade.php .

signup.blade.php page has code something like this:

@include('welcome')

@section('title')

    measurement

@endsection

@section('signup')
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <form action="">
                <input type="text" class="form-control">
            </form>
        </div>
    </div>
</div>

@endsection

The structure of the files is like this :

resources/views/welcome.blade.php

resources/views/layouts/signup.blade.php

But the problem is neither the title is showing when I load welcome.blade.php neither the sign up form appears.

Note: The title is showing localhost:8000 , don't know why ?

Am I doing anything wrong, please help me thanks.

Your master template welcome.blade.php

<!DOCTYPE html>
<html>
    <head>
        <title>
            @yield('title')
        </title>
    </head>
    <body>
         @yield('content')
    </body>
</html>

And now any page that will use this template need to extends it. In your case signup.blade.php

@extends('welcome')

@section('title')

    measurement

@endsection

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <form action="">
                <input type="text" class="form-control">
            </form>
        </div>
    </div>
</div>

@endsection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM