Using just @yield()
you wont be able to have a default content.
Using @section()..@show
you'll be able to have a default content and you can do stuff like
<title>
@section('title')
Laravel
@show
</title>
Then on one of your views you can do the following
@section('title')
@_parent (remove the _, the forum removes the whole call for some weird reason)
:: Some page
@stop
Which will result on
<title>
Laravel :: Some Page
</title>
Notice the @_parent
you can position it before or after the content and it will inherit your default content, if you don't use @_parent
the default will be completely replaced.
Hope it helps.
@yield('some_section') actually creates a section in master layout.
<!DOCTYPE html>
<html lang='en'>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>@yield('title') | User Admin</title>
<link rel='stylesheet' href=bootstrap.min.css'>
</head>
<body>
<div class='container-fluid'>
<div class='row'>
@yield('content')
</div>
</div>
</body>
</html>
@section('some_section') makes it work in general template, which extends master @extends('master_layout')
@extends('layouts.master')
@section('title')
Login
@stop
@section('content')
<div>
content
</div>
@stop
This way u have full control over your html output.
brunogaspar said:
Using just
@yield()
you wont be able to have a default content.Using
@section()..@show
you'll be able to have a default content and you can do stuff like<title> @section('title') Laravel @show </title>
Then on one of your views you can do the following
@section('title') @_parent (remove the _, the forum removes the whole call for some weird reason) :: Some page @stop
Which will result on
<title> Laravel :: Some Page </title>
Notice the
@_parent
you can position it before or after the content and it will inherit your default content, if you don't use@_parent
the default will be completely replaced.Hope it helps.
With @yield i am able to have default content:
@yield('section', 'default value')
I have figured out myself:
show is used in case if you need to use parent and append content to a parent.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community