douyunjiaok300404 2016-08-01 05:24
浏览 104
已采纳

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 05: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部