dtp87205 2016-05-22 14:43
浏览 47
已采纳

@yield只使用1个包含网页的多个网页上的页眉和页脚

i 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
  • 写回答

1条回答 默认 最新

  • dongpan1871 2016-05-22 14:53
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘