PHP Geek PHP Geek - 3 months ago 23
PHP Question

Extending the header and footer in laravel

I am using laravel 5.2 to create a new project. As i am new in the laravel. so I am creating new page and directory structure is as follows:
-views
- layouts
- default.blade.php
- page
- index.blade.php
- templates -common
- header.blade.php
- footer.blade.php

Now in page/index.blade.php I need to extend the default layout. my codes are as below..
LAYOUTS/DEFAULT.BLADE.PHP

@include('templates.common.header')
@yield('section')
@include('templates.common.footer')


and in index page i have defined the section but resulting the error as follows:

FatalErrorException in 1d36838b56f16e2e06a8567cdd5270af26ec6aa8.php line 1: syntax error, unexpected '__data' (T_STRING)


Please suggest me some solutions....
Thank you

Answer

in your structure templates - header.blade.php - footer.blade.php no directory common in templates, which is in

@include('templates.common.header')

Also check you have at first line in index.php: @extends('layouts.default')

Comments