Art*_*gio 0 php view laravel blade
我正在学习Laravel,我想知道如何将多个视图结合在一起.
我查看了laravel.com上的文档,找不到告诉我如何连接视图的部分.
我已经解决了这个问题(在我的控制器中):
public function showPage() {
return View::make('header') . View::make('content') . View::make('footer');
}
Run Code Online (Sandbox Code Playgroud)
但肯定有更好/更正确的方式......我将不胜感激任何帮助.
你可以加载这样的东西
public function showPage() {
return View::make('page');
}
Run Code Online (Sandbox Code Playgroud)
在你的page.blade.php:
@include('header')
@include('content')
@include('footer')
Run Code Online (Sandbox Code Playgroud)
但实际上拥有这种结构会更好.
layout.blade.php:
@include('header')
@yield('content')
@include('footer')
Run Code Online (Sandbox Code Playgroud)
page.blade.php:
@extends('layout')
@section('content')
HTML of content here...
@stop
Run Code Online (Sandbox Code Playgroud)