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 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型