I am trying to set up a site using laravel, but I'm really having trouble with basic things that the documentation just doesn't cover.

在这种情况下,我看到它说我可以使用@include('view.name')将一个视图包含在另一个视图中.什么是景观.名称它保存在哪里?我试图创建一个文件app/views/view.name.blade.php,但没有被读取.文件名如何映射到Blade 名称?

推荐答案

EDIT: Below was the preferred solution in 2014. Nowadays you should use @include, as mentioned in the other answer.


In Laravel views the dot is used as folder separator. So for example I have this code

return View::make('auth.details', array('id' => $id));

它指向app/views/auth/Details.blade.php

And to include a view inside a view you do like this:

file: layout.blade.php

<html>
  <html stuff>
  @yield('content')
</html>

file: hello.blade.php

@extends('layout')

@section('content')
  <html stuff>
@stop

Laravel相关问答推荐

Laravel 数据未传递到下拉框

如何通过单击进入 vs 代码中的类

如何在 Laravel 中填充以后执行的条件

Laravel Valet 安装后 Ping test.dev 返回未知主机

从 Laravel Session 数组中删除项目

如何在 Laravel 4 中使用没有 id 的 Eloquent 更新数据

如何修复无效请求(不支持的 SSL 请求)

升级到 laravel 5.4 后调用未定义的方法

laravel 中的 Http Post 使用 fetch api 给出 TokenMismatchException

Laravel 使用 Storage::put 生成唯一 ID

laravel 4 - 如何限制(采取和跳过)Eloquent的 ORM?

Laravel 5:在同一字符串上使用 bcrypt 给出不同的值

未找到列:1054 未知列 laravel

Laravel 验证 pdf mime

Laravel 获取文件内容

如何以 JSON 格式发送 Laravel 错误响应

php artisan migrate - SQLSTATE [HY000] [1045] 用户'laravel'@'localhost'的访问被拒绝

同一模型上的 Laravel 父/子关系

如何从 PHPUnit 测试设置运行 Laravel 数据库 seeder 机?

Laravel 5.3 - 用户Collection 的单一通知(关注者)