我只有1页名为include.blade.php,它只包含页眉,页脚和导航栏的@section。 我想使用这个页面,所以每次我创建一个网页,我只是打电话给它。 所以i @ yield-ed到另一个页面(index.blade.php)并且工作得非常好。 但当我同时将它@yield到另一个名为(grades.blade.php)的页面时,它会显示index.blade.php网页和grade.blade.php。 所以浏览器在一个浏览器窗口中附加2个网页。 我如何拥有一个include.blade.php,它在每个页面都有我需要的页脚和标题,只是@yield到处或者不可能只有一个?
我在include.blade.php中的代码:
@extends('index') @section('footer')<footer class="section" ><div class="container"> <div class="row"> <div class="col-xs-12 col-md-6 col-lg-6 col-sm-6 "> <p> <br> © Copyright Pgasinan 2015 <br>ArelStreet, <br>Dagupa 2400 <br>Phs </p> </div></div></div></footer>@endsection @section('navbar')<div class="navbar navbar-default" id="mynav"><div class="container"><div class="navbar-header" > <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#" id="brand"><span>Univean</span></a> </div> <div class="collapse navbar-collapse" id="navbar-ex-collapse"> <ul class="nav navbar-nav navbar-right"> <li> <a href="/">Home</a> </li> <li> <a href="#sec1">Academics</a> </li> <li> <a href="#faq">FAQs</a> </li> <li> <a href="/login">Login</a> </li> </ul> </div> </div> </div> @endsection @section('cssandjs') <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="js/bootstrap.min.js"></script> <link rel="stylesheet" type="text/css" href="css/default.css"> <link rel="stylesheet" type="text/css" href="css/style.css"> @endsectioni have only 1 page named include.blade.php and it contains the @section for header, footer and navbar ONLY. i want to use this page so everytime i make a webpage, i just call it. so i @yield-ed it into another page (index.blade.php) and works super fine. but when i also @yield it to another page named (grades.blade.php) it shows the index.blade.php webpage and the grade.blade.php. so the browser appends 2 webpage in a single browser window. how do i have a single include.blade.php having the footers and headers i need in every single pages and just @yield it everywhere or it is not possible to have just one?
my code in include.blade.php:
@extends('index') @section('footer')<footer class="section" ><div class="container"> <div class="row"> <div class="col-xs-12 col-md-6 col-lg-6 col-sm-6 "> <p> <br> © Copyright Pgasinan 2015 <br>ArelStreet, <br>Dagupa 2400 <br>Phs </p> </div></div></div></footer>@endsection @section('navbar')<div class="navbar navbar-default" id="mynav"><div class="container"><div class="navbar-header" > <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#" id="brand"><span>Univean</span></a> </div> <div class="collapse navbar-collapse" id="navbar-ex-collapse"> <ul class="nav navbar-nav navbar-right"> <li> <a href="/">Home</a> </li> <li> <a href="#sec1">Academics</a> </li> <li> <a href="#faq">FAQs</a> </li> <li> <a href="/login">Login</a> </li> </ul> </div> </div> </div> @endsection @section('cssandjs') <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="js/bootstrap.min.js"></script> <link rel="stylesheet" type="text/css" href="css/default.css"> <link rel="stylesheet" type="text/css" href="css/style.css"> @endsection最满意答案
您的问题来自模板顶部的扩展索引。 您不应该在“包含”页面上扩展完整布局。
您似乎应该拥有两个(或可能更多)布局模板,例如索引,在这些模板中,您可以包含“包含”页面。 然后对于成绩,您只需扩展新布局而不是索引。 您不必担心在页面中包含页眉,页脚和导航栏。 他们应该只是简单地扩展布局。
请进一步阅读https://laravel.com/docs/5.1/blade
Your issue resides from your extending index at the top of your template. You shouldn't be extending a full layout on an "include" page.
It seems to be you should have two (or possibly more) layout templates, like index, and in those templates you can include the "include" page. Then for grades, you just extend the new layout instead of index. You shouldn't have to worry about including the header, footer, and navbar within your pages. They should just simply extend a layout.
Read further at https://laravel.com/docs/5.1/blade
更多推荐
php,class,blade,电脑培训,计算机培训,IT培训"/> <meta name="description&q
发布评论