From the laravel documentation, what do the 'sidebar' and 'content' ask for: a separate child document or something that is still to be made?

Viewed 33

So i'm verry new to stackoverflow and Laravel so here goes nothing!

I do not get the laravel documentation where the yield and section call for certain things because i don't know what those called things are. So if u see this documentation:

<html>
<head>
    <title>App Name - @yield('title')</title>
</head>
<body>
    @section('sidebar')
        This is the master sidebar.
    @show

    <div class="container">
        @yield('content')
    </div>
</body>

The title, sidebar and content are confusing my tiny brain and its stressing me. Pleas explain me. (Also i'm not a native english speaker sorry for any typos.)

1 Answers

Example

Consider you have a simple index page that consists of basic html and css, now you will 2 more pages about and contacts like this page, first thing you will notice that all 3 pages have the same layouts and section but they are different in page title and content

so instead of rewriting those section over and over again in every new page we have to do something else

Solution

We can make a general skeleton of those pages and it's called master layout like so

<html>
   <head>
     <title>App Name - @yield('title')</title>
   </head>
   <body>
   <div class="container">
      @yield('content')
   </div>
  </body>

now every new page you create will extends that layout and each page have to add it's title and content

@extends('master')
@section('title')
   About Us
@endsection
@section('content')
   <div>about us page content goes here</div>
@endsection

about us page now has it's own unique data but it has the layout with other pages.

Note that: a yield in a layout page represents a section in extended page

Related