[英]Laravel blade templating yield not working
I have a layouts/app.blade.php
view where I yield a content section. 我有一个
layouts/app.blade.php
视图,我在其中生成一个内容部分。
layouts/app.blade.php 布局/ app.blade.php
@yield('content')
adminpanel/adminpanel.blade.php adminpanel / adminpanel.blade.php
@extends('layouts.app')
@section('content')
<div id="wrapper">
<div id="sidebar-wrapper">
@yield('sidebar')
</div>
<div id="page-content-wrapper">
<div class="container-fluid">
@yield('page-content')
</div>
</div>
</div>
@endsection
adminpanel/sidebar.blade.php adminpanel / sidebar.blade.php
@extends('adminpanel.adminpanel')
@section('sidebar')
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Profile
</a>
</li>
<li>
<a href="#">Dashboard</a>
</li>
<li>
<a href="#">News</a>
</li>
</ul>
@endsection
Am I doing something wrong here? 我在这里做错了吗?
When I type something in the adminpanel/adminpanel.blade.php
view it works but the yielding of partials doesn't work. 当我在
adminpanel/adminpanel.blade.php
视图中键入内容时,它可以正常工作,但部分的屈服不起作用。
If you are returning the "adminpanel/adminpanel", then you must include the sidebar from the admin-panel, not "yield" something for what you don't have the contents. 如果您要返回“adminpanel / adminpanel”,那么您必须包含来自管理面板的侧边栏,而不是“屈服”某些内容,因为您没有内容。
@include('adminpanel.sidebar')
instead of 代替
@yield('page-content')
and then in your sidebar, remove all blade directives because they are no longer needed. 然后在侧边栏中删除所有刀片指令,因为它们不再需要。
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Profile
</a>
</li>
<li>
<a href="#">Dashboard</a>
</li>
<li>
<a href="#">News</a>
</li>
</ul>
try include adminpanel/adminpanel.blade.php 尝试包括adminpanel / adminpanel.blade.php
@extends('layouts.app')
@section('content')
<div id="wrapper">
<div id="sidebar-wrapper">
@include('adminpanel.sidebar')
</div>
<div id="page-content-wrapper">
<div class="container-fluid">
@yield('page-content')
</div>
</div>
</div>
@endsection
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.