@extends ('layout') laravel. Blade Template System looks like it doesn't work

I tried using the laravel: blade template system but it doesn't seem to work when using the code below in users.blade.php file:

 @extends('layout') @section('content') Users! @stop 

and browser

  @extends('layout') 
+10
php laravel
source share
7 answers

This should work if you have a template file in /app/views/layout.blade.php containing

 <p>Some content here</p> @yield('content') <p>Some additional content here</p> 

Then in your /app/views/user.blade.php content

 @extends('layout') @section('content') <p>This is the user content</p> @stop 

If you call return View::make('user') , you must have compiled content

 <p>Some content here</p> <p>This is the user content</p> <p>Some additional content here</p> 

I hope this helps you clarify the situation. If not, can you indicate the location of the template files and related content?

+7
source share

Just remove the extra space or something else before @extends ('yourlayoutfile').

This should be the first thing to do in the file.

I ran into the same problem and tried many things. Suddenly I found one place when starting the file before @extends.

The space is removed and it works fine.

Thanks.

Format:

 @extends('layouts.default') @section('content') ..... @stop 

--- Edit ----

If this does not work, try:

Copy all the contents to a file and then delete the file.

Create a new file and save it as filename.blade.php

Only after saving the file, paste the contents on the page. Save the changes and run them.

It works.

Thanks.

+2
source share

Where is your layout located?

If its in app/views/layouts , then this should be

 @extends('layouts.index') 

(assuming the name is index.blade.php)

ex: @extends('layouts.foo') is equal to the file in app/views/layouts/ called either foo.blade.php or foo.php . (depending on whether you use a blade)

+1
source share

I have the same problem. What has been done: 1. in routes.php

 Route::get('about', ' AboutController@index '); 

that AboutController is the controller file AboutController.php in the application / index controllers is a function inside this controller.

2.Create AboutController.php in the application / controllers

 class class AboutController extends BaseController { protected $layout = 'layouts.default'; $this->layout->content = View::make('pages.about'); } 

You can see this link: Defining the layout on the controller

+1
source share

By default, Laravel has a layouts folder inside the views folder, i.e. app/views/layouts , and in this folder you save layout files, i.e. app/views/layouts/index.master.php , and if you have something similar you should use something like:

 @extends('layouts.master') @section('content') <p>Page Content</p> @stop 

This inherits / uses the master.blade.php file (as a layout) from the layouts folder, here layouts.master means layouts/master.blade.php .

In your master.blade.php file you have this

 @yield('content') 

So, the data / content from the view between @section('content') and @stop will be reset instead of @yield('content') your layout.

You can use any name for your layout file, if it is layouts/main.blade.php , then you should use

 @extends('layouts.main') 
0
source share

let's say you have "master.blade.php" and "index.blade.php". and both files are in view-> home directory. if you want to use @extends in 'index.blade.php' by calling 'master.blad.php', you should write this status in index.blade.php:

 @extends('home.master') 

not

 @extends('master') 
-one
source share

Just save your source using UTF-8 without signature encoding UTF-8 without signature .

-3
source share

All Articles