1

To extend a blade template you have to write

@extends('folder.template_name') 

This works for standard installation.

I've created a module for the backend and now I can't use my module template because Laravel catches the first record and that is the standard view folder.

My structure looks like this:

app -- modules -- modules\backend -- modules\backend\views -- modules\backend\views\layouts\master.blade.php -- views -- views\layouts\master.blade.php 

So when I'm in the backend and try to display my template:

// app\modules\backend\views\page\index.blade.php @extends('layouts.master') 

Laravel renders the app\views\layouts\master.blade.php instead of app\modules\backend\views\layouts\master.blade.php

I've tried many names inside that @extends e.g.

@extends('app\modules\backend\views\layouts\master') @extends('app.modules.backend.views.layouts.master') @extends(base_path(). '\app\modules\backend\views\\' . 'layouts.master') 

Nothing works.

2 Answers 2

5

While using a package or autoloaded module, referring to it's resources is done using the double colon notation. In your case, to access the module's master template you need to use

@extends('backend::layouts.master') 

These conventions are described in the docs, for further info please refer to

Laravel 4 package conventions

Sign up to request clarification or add additional context in comments.

3 Comments

That is the solution. It works!!! Can you tell me please where I can find more about this? Do you have any sources about that?
that is the notation that you use in other places (View::make , Config::get, etc.) to denote that you are reffering to a package or module so I thought it might work also for your case. I am not sure if this info is listed anywhere in the documentation...
I see it is already updated into the docs, I edited my answer to include this.
0

Make sure /app/config/view.php has a path entry for where those views are located.

I.E.

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

To

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

or whatever represents your actual path.

From here you might want to look into doing the view folder loading via another mechanism if your views are in dynamically generated folders. Maybe a module::boot event that adds the module path to the view paths array? Just an idea.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.