Laravel 刀片布局

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15323567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:36:40  来源:igfitidea点击:

Laravel Blade Layouts

phpframeworkslaravel

提问by user2051012

This is the problem, its not reading @layout()

这就是问题所在,它没有读取@layout()

its not reading

它不读书

Inside the folder View/authors/index.blade.php

View/authors/index.blade.php 文件夹内

@layout('layouts.default')

@section('content')

Authors Home Page

@endsection

@layout('layouts.default')

@section('内容')

作者主页

@endsection

In the folder Controllers/authors.php

在文件夹 Controllers/authors.php 中

class Authors_Controller extends Base_Controller{

  public $restful = true;

  public function get_index(){
      return View::make('authors.index')->with('title', 'Autores e Livros');
  }

}

类 Authors_Controller 扩展 Base_Controller{

  public $restful = true;

  public function get_index(){
      return View::make('authors.index')->with('title', 'Autores e Livros');
  }

}

and inside the folder View/layouts/default.blade.php

并在文件夹 View/layouts/default.blade.php 内

basic html

基本的html

<html>
<head> <title> {{ $title }} </title> </head>
<body>
{{ $content }}
</body>
</html>

Where's my error? why is it not reading?

我的错误在哪里?为什么不读书?

Folder

文件夹

回答by Mr. Sensitive

First: Inside View/layouts/default.blade.php

第一:内部视图/布局/default.blade.php

<html>
<head> <title> {{ $title }} </title> </head>
<body>
  @yield('content')
</body>
</html>

And second: Update

第二:更新

I'm like 99% sure that '@layout('layouts.default')' in your View/authors/index.blade.php is not on the first line. It has to be at the top of the page.

我 99% 确定 View/authors/index.blade.php 中的 '@layout('layouts.default')' 不在第一行。它必须位于页面顶部。

回答by Shnd

It seems in Laravel 4 you should use @extends('layouts.default')instead of @layout('layouts.default')

似乎在 Laravel 4 中你应该使用@extends('layouts.default')而不是@layout('layouts.default')