我有layouts.app.blade.php,其中我有和标签以及
Toggle Navigation *Dynamic page title* // ... @yield('content')
我想使用这个来显示我的pagetitle。 所以这意味着它必须在这个’parent.blade.php’中为每个加载的模板(使用@yield(’content’))进行更改。
我如何使用Laravel 5.2做到这一点?
非常感谢
如果这是您的母版页标题
App Name - @yield('title') @section('sidebar') This is the master sidebar. @show @yield('content')
然后您的页面标题可以在您的刀片页面中更改,如下所示
@extends('layouts.master') @section('title', 'Page Title') @section('sidebar') @parent This is appended to the master sidebar. @endsection @section('content') This is my body content. @endsection
This is appended to the master sidebar.
This is my body content.
更多信息可以在这里找到Laravel Docs
例如,您可以将其传递给视图
调节器
$title = 'Welcome'; return view('welcome', compact('title'));
视图
isset($title) ? $title : 'title';
或者php7
$title ?? 'title';
空结合运算符
刀片视图如下 –
return view('front.list',compact('artists','letter'));
代替-
return view('front.list',compact('artists'));
现在在您的视图中,您可以使用:
Artists begging with {{ $letter }}