douyunjiaok300404 2016-08-01 13:24
浏览 103
已采纳

Laravel - 使用yield / extends

I have an @include problem with my bootstrap navbar. I worked on it this morning and I really don't know where the problem is.

Here is the error message :

View [layouts.navbar] not found.

I want to include the content of navbar.blade.php

<!DOCTYPE html>
<html>
<head>
<title>Mana Tournaments</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
{!! Html::style('css/style.css') !!}
{!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css')  !!}
{!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css') !!}
</head>
<body>
<div class="container">
<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">Logo</a>
        </div>
        <ul class="nav navbar-nav">
            <li class="active"><a href="welcome">Accueil</a></li>
            <li><a href="#">Tournois</a></li>
            <li><a href="#">Inscription</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </div>
</nav>
</div>
</body>
</html>

To my index page (welcome.blade.php)

<!DOCTYPE html>
<html>
    <head>
    <title>Mana Tournaments</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
    {!! Html::style('css/style.css') !!}
    {!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css')  !!}
    {!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css') !!}
    </head>
<body>
<h1>Gestionnaire de tournois</h1>
<div class="container">
 @include('layouts.navbar')
 </div>
 </body>
</html>

I created manually a layout folder, then i created the navbar file. If I did someting wrong, maybe there's a command line for laravel for creating a folder ?

Thank you for helping me on my problem.

  • 写回答

2条回答 默认 最新

  • douye8500 2016-08-01 13:30
    关注

    First of all,

    Make sure the view you're including exists in the correct folder.

    @include('layouts.navbar') will include that path esources\views\layouts avbar.blade.php

    Make sure, The file within layouts directory,

    Second, You don't need to write the whole html for the included part. navbar.blade.php will be added (included) to welcome.blade.php, it's like you're copying the content of navbar.blade.php and adding it to welcome.blade.php,

    So make it like this instead,

    navbar.blade.php

    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">Logo</a>
            </div>
            <ul class="nav navbar-nav">
                <li class="active"><a href="welcome">Accueil</a></li>
                <li><a href="#">Tournois</a></li>
                <li><a href="#">Inscription</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </div>
    </nav>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?