Reputation: 6842
I tried to use the laravel's template system: blade
but seems like not working when using the code below in the file users.blade.php
:
@extends('layout')
@section('content')
Users! @stop
and browser,
@extends('layout')
Upvotes: 14
Views: 69682
Reputation: 3790
Try this!
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan clear-compiled
Upvotes: 0
Reputation: 19
list things to make sure
file name and path properly given
double-check .blade.php file extention
layouts.admin.blade.php
<section class="content" style="padding-top: 20px">
@yield('content')
</section>
@extends('layouts.admin')
@section('content')
<p> this is Order index view</p>
@endsection
Upvotes: 0
Reputation: 73
Make sure you inserted the css link in App.blade.php
For me By default there is no link to the css file
Insert the following link in app.blade.php
<link rel="stylesheet" href= "/css/app.css" >
now its works fine :)
Upvotes: 0
Reputation: 554
That should work if you have a template file at /app/views/layout.blade.php that contains
<p>Some content here</p>
@yield('content')
<p>Some additional content here</p>
Then in your /app/views/user.blade.php, the content
@extends('layout')
@section('content')
<p>This is the user content</p>
@stop
If you call return View::make('user')
you should have the compiled content
<p>Some content here</p>
<p>This is the user content</p>
<p>Some additional content here</p>
I hope that helps clarify things for you. If not, can you provide your template file locations and the relevant content?
Upvotes: 10
Reputation: 307
let's say you have 'master.blade.php' and 'index.blade.php'. and both of files are in views->home directory. when you want to use @extends in 'index.blade.php' by calling 'master.blad.php' , you should write in index.blade.php file this statment:
@extends('home.master')
not
@extends('master')
Upvotes: -1
Reputation: 571
Just remove the extra space or anything before @extends('yourlayoutfile').
It should be the first thing to be rendered in the file.
I was facing the same problem and tried many things.Suddenly I found a single space at the starting of the file before @extends.
Removed the space and is working fine.
Thanks.
Format:
@extends('layouts.default')
@section('content')
.....
@stop
---Edit----
If this didnt work then try :
Copy all the content in the file and then delete the file.
Create a new file and save it as filename.blade.php
Only after saving the file paste the content into the page. Save the changes and run it.
This works.
Thank you.
Upvotes: 2
Reputation: 29
I have the same problem. What is did is: 1. in routes.php
Route::get('about', 'AboutController@index');
that AboutController is a controller file AboutController.php in app/controllers index is a function inside that controller.
2.Create AboutController.php in app/controllers
class class AboutController extends BaseController {
protected $layout = 'layouts.default';
$this->layout->content = View::make('pages.about');
}
You can look at this reference: Defining A Layout On A Controller
Upvotes: 1
Reputation: 146191
By default,Laravel
has a layouts
folder inside views
folder, i.e. app/views/layouts
and in this folder you keep your layout files, i.e. app/views/layouts/index.master.php
and if you have something similar then you should use something like this:
@extends('layouts.master')
@section('content')
<p>Page Content</p>
@stop
This will inherit/use the master.blade.php
file (as layout) from layouts
folder, here, layouts.master
means layouts/master.blade.php
.
In your master.blade.php
file you mast have this
@yield('content')
So, data/content from the view between @section('content')
and @stop
will be dumped in the place of @yield('content')
of your layout.
You can use any name for your layout
file, if it's layouts/main.blade.php
then you should use
@extends('layouts.main')
Upvotes: 0
Reputation: 3330
Where is your layout?
If its in app/views/layouts
, then it should be
@extends('layouts.index')
(assuming the name is index.blade.php)
ex: @extends('layouts.foo')
equals a file in app/views/layouts/
called either foo.blade.php
or foo.php
. (depending if you use blade)
Upvotes: 1