@extends('layouts')
@section('header')
@parent
header
@stop
@section('sidebar')
@parent
sidebar
@stop
@section('content')
content
@stop
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>轻松学会Laravel - @yield('title')</title>
<style>
.header{
width:1000px;
height:150px;
margin:0 auto;
background:#f5f5f5;
border: 1px solid #ddd;
}
.main{
width:1000px;
height:300px;
margin:0 auto;
clear:both;
margin-top:15px;
}
.main .sidebar{
float:left;
width:20%;
height: inherit;
background: #f5f5f5;
border: 1px solid #ddd;
}
.main .content{
float:right;
width:75%;
height:inherit;
background:#f5f5f5;
border: 1px solid #ddd;
}
.footer{
width:1000px;
height:150px;
margin:0 auto;
margin-top:15px;
background:#f5f5f5;
border:1px solid #ddd;
}
</style>
<body>
<div class = "header">
@section('header')头部@show
</div>
<div class = "main">
<div class = "sidebar">
@section('sidebar')
侧边栏
@show
</div>
<div class = "content">
@yield('content','主要内容区域')
</div>
</div>
<div class = "footer">
@section('footer')
底部
@show
</div>
</body>
</html>
Blade


模板继承涉及知识点
Blade介绍
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>轻松学会Laravel - @yield('title')</title>
<style>
.header{
width:1000px;
height:150px;
margin:0 auto;
background:#f5f5f5;
border: 1px solid #ddd;
}
.main{
width:1000px;
height:300px;
margin:0 auto;
clear:both;
margin-top:15px;
}
.main .sidebar{
float:left;
width:20%;
height: inherit;
background: #f5f5f5;
border: 1px solid #ddd;
}
.main .content{
float:right;
width:75%;
height:inherit;
background:#f5f5f5;
border: 1px solid #ddd;
}
.footer{
width:1000px;
height:150px;
margin:0 auto;
margin-top:15px;
background:#f5f5f5;
border:1px solid #ddd;
}
</style>
<body>
<div class = "header">
@section('header')头部@show
</div>
<div class = "main">
<div class = "sidebar">
@section('sidebar')
侧边栏
@show
</div>
<div class = "content">
@yield('content','主要内容区域')
</div>
</div>
<div class = "footer">
@section('footer')
底部
@show
</div>
</body>
</html>
更改布局文件内容
控制器输出视图
定义内容区域和尾部
定义头部和侧边栏
公共模板布局
把父模板中的内容输出来:
@section('header')
@parent
自定义的内容
@stop
中加入
blade模板引擎
yield 和 session 的区别,视频中 yield 和 session 都是用 @session ... @stop 定义