【问题标题】:View master layout not found未找到查看主布局
【发布时间】:2015-01-14 23:53:58
【问题描述】:

我是 laravel 的新手。但是,我创建了刀片模板并与我的离线索引网页集成。它由signin.html 和signout.html 组成。所以下面是管理我的文件的结构方式:

-views 
--account
---signin.blade.php
---signup.blade.php
--includes
---head.blade.php
---footer.blade.php
--layouts
---master.blade.php
--home.blade.php

Home.blade.php

@extends('layouts.master');

Master.blade.php

<!DOCTYPE html>
<html>
<head>
    @include('includes.head');
</head>
<body class="bg-info">
    <!-- @include('includes.navigation'); -->

    <!-- @extends('account.signin'); -->

    <!-- @yield('content') -->      
     <!-- @yield('content') -->

    @include('includes.footer'); 
</body> 
</html>

以下两个文件会在页面中输出登录表单。我不知道他们是如何进入其中的。我没有包括任何东西。我的公共文件夹:

--assets
---css
---fonts
---images
---js
--index.php
--.htacess

Index.php

require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
$app->run();
$app->shutdown();

.htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

路线

Route::get('/', array (
 'as' => 'home',
 'uses' => 'HomeController@home'
));

家庭控制器

public function home() {
    return View::make('home');
}

现在,如果我打开我的本地主机,查看 [includes.master] 未找到。可能我的存储文件夹中还包含模板代码,但我尝试删除,它不断生成一个新的。

另一个问题是当我将@extends('includes.master') 添加到顶部的signin.blade.php 或singup.blade.php 中时。 localhost 和 localhost/account/signin 或 localhost/account/register 将是 Internal Server Error: 500

【问题讨论】:

  • 如果有部分,请尝试将@stop 放在扩展布局的视图末尾
  • 如果你能告诉我们你的路线和 HomeController 请
  • @EimantasGabrielius 我做了,但还是没用。
  • 那么“includes.master”包含在哪里?因为我在你的代码中找不到,但是错误说 [includes.master] 没有找到。

标签: php html .htaccess laravel view


【解决方案1】:

好吧,让我告诉你一些事情。需要从外部文件夹中包含您的标题吗?请按照这个,你的主布局应该是这样的:

<!DOCTYPE html>
<html>
<head>
  //put your codes here , not the include function
</head>
<body class="bg-info">
  @include('includes.navigation');

  @extends('account.signin');

  @yield('content')

  @include('includes.footer'); 
</body> 
</html>

home.blade.php应该是这样的:

@extends(layouts.master) 
@section('content')
 <p> Hello, this works </p>
@stop

如果您需要任何进一步的帮助,请告诉我。

【讨论】:

  • 查看 [includes.master] 未找到。 (查看:..\laravel\app\views\account\signin.blade.php)(查看:..\laravel\app\views\account\signin.blade.php)
  • 我的应用程序/存储文件夹中有以前的代码。它包含我现在注释掉的所有以前的代码。
  • 检查文件扩展名和大写问题。如果您命名为 Master.blade.php,则不能将其称为“master”。
  • 你听我的回答了吗?
  • 是的,我完全按照您的代码进行操作,并且大写和文件扩展名运行良好。但仍然会出现错误。
【解决方案2】:

检查views 文件夹权限。就我而言,有一个问题。

对于这个文件夹和permissions中的所有文件应该是755

【讨论】:

    【解决方案3】:

    有同样的问题,认为这与视图目录的刀片缓存有关。我通过将@extends(example.master) 更改为另一个模板然后回到想要的路径 来修复它。没有做任何其他事情,但一如既往地先尝试php artisan view:clear

    你好,帕特

    【讨论】:

      猜你喜欢
      • 2020-02-15
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 1970-01-01
      • 2017-03-28
      • 1970-01-01
      • 2022-09-27
      • 1970-01-01
      相关资源
      最近更新 更多