3
我laravel视图结构是这样的:Laravel视图,布局和变量传递
/views/layouts/default.blade.php
含有
<html>
@yield('header')
<body>
@yield('navigation')
@yield('content')
@yield('footer')
</body>
以下通过
/views/partials/footer.blade.php
/views/partials/header.blade.php
/views/partials/navigation.blade.php
以我头视图我有一个var $ title 我试图在主页上动态设置控制器。
所以在位于/pages/index.blade.php 我认为我得到了这个
@layout('layouts.default')
@section('header')
@render('partials.header')
@endsection
@section('navigation')
@render('partials.menu')
@endsection
@section('footer')
footer
@endsection
@section('content')
@endsection
我读的地方,标题var目录应该throught控制器传递,但我不能做到这一点: (
我想这没有任何成功。$标题在头谐音意见未定义..
class Home_Controller extends Base_Controller {
public $layout = 'layouts.default';
public function action_index()
{
$this->layout->nest('header', 'home.index')->with('title', 'James');
$posts = Post::with('author')->all();
return View::make('home.index');
}