سؤال

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