Search code examples
phplaravelsyntaxlaravel-bladedirectory-structure

Laravel 4, Blade include template from parent directory - dot notation


I have a directory structure as following:

views/
-----common.blade.php
-----module1/
----------index.blade.php

I have my views path set to module1

I want to access common.blade.php from index.blade.php, however it gives me a blank page.

I have tried @include('..\common'), @include('/../common'), @include('//..//common'), @include('\..\common'), @include('common')

I understand it uses dot notation, how do I access parent directory in dot notation?

Zain


Solution

  • Like suggested in the comments you need to provide simple, root based path:

    @include('common')
    

    The view paths in include are always absolute to the views base directory, app/views by default.

    You can alter (or add more paths) it in the app/config/view.php file:

    // default
    'paths' => array(__DIR__.'/../views'),