How do I pass a variable to the layout using Laravel' Blade templating?

后端 未结 11 2112
猫巷女王i
猫巷女王i 2021-01-30 03:30

In Laravel 4, my controller uses a Blade layout:

class PagesController extends BaseController {
    protected $layout = \         


        
11条回答
  •  灰色年华
    2021-01-30 04:11

    In the Blade Template : define a variable like this

    @extends('app',['title' => 'Your Title Goes Here'])
    @section('content')
    

    And in the app.blade.php or any other of your choice ( I'm just following default Laravel 5 setup )

    {{ $title or 'Default title Information if not set explicitly' }}
    

    This is my first answer here. Hope it works.Good luck!

提交回复
热议问题