Thursday, 5 September 2013

Basic Laravel4 yield not working?

Basic Laravel4 yield not working?

Recently began learning laravel4 and i am experimenting with blade
templates. For some reason these was working but all of a sudden they have
stopped working and when i go to view the site with said template on it
just shows the @yield directive and not displaying the section its meant
to be .
http://i.imgur.com/kf0fdjH.png <-- screenshot of source when viewed in
browser
This is all the code i am using currently this is dead basic stuff
app/routes.php
//set base route
Route::get('/', 'HomeController@index');
app/controllers/HomeController
<?php
class HomeController extends BaseController {
protected $layout = 'base';
public function index()
{
$data = array(
'heading' => 'Hello Laravel (from Home)',
'body' => 'This is awesome, from the HomeController'
);
$this->layout->content = View::make('test', $data);
}
}
app/views/base.php (html layout template)
<!doctype html>
<html>
<head>
<title>Something</title>
</head>
<body>
<div class="container">
@yield('content')
</div>
</body>
</html>
app/views/test.blade.php
@section('content')
<h1>{{ $heading }}</h1>
<p>{{ $body }}</p>
@stop
Thats pretty much it i have no idea why its not showing up when i view the
site. This did work and then for some reason stopped and i have no idea
why. I have even tried a fresh install of laravel with the same results.

No comments:

Post a Comment