문제

I'd like to split my layouts into partials.

I'm creating a default blade layout.

The file is called default.blade.php, and lives in the layout folder.

Also under the layout folder is include. In this dir, I have head.blade.php

I would like to call 'head' from 'default'.

Every one of these fails and returns an error when debug is turned on:

@include('include/head'),  @include('include/head.blade.php'), @include('include/head.blade.php')

I have copied head.blade.php into the same folder as default.blade.php, and still get errors.

도움이 되었습니까?

해결책

You need to give the full path relative to your view folder. Try doing this :

@include('layout.include.head')

다른 팁

Keep in mind that Laravel uses dot notation to organize the templates and their parts.

So, the main.blade.php template in your main /views folder should be included directly:

@include ('main')

A main.blade.php template in a, e.g. /views/layouts folder should be called as:

@include ('layouts.main')

and so on.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top