I'm working on learning Laravel and while the quickstart taught me a lot I've been having nothing but problems trying to build off of that.
Currently, I'm trying to use a file public.blade.php
as the main public layout for my site. This is working correctly. Within that file, I am trying to display @yield('title')
and and @yield('content')
within it, this is the part I am having issues with.
Within app/views/public.blade.php
I have the following structure:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>@yield('title')</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
...
... <!--layout code would be here-->
...
<div class="container">
<div class="container">
@yield('content')
<hr />
<footer>
<p>© Example Site 2013</p>
</footer>
</div> <!-- /container -->
Within app/views/home.blade.php
I have the following:
@extends('public')
@section('title')
@parent
BootstrapCMS
@stop
@section('content')
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="hero-unit">
<h1>Welcome!</h1>
<p>The goal of BootstrapCMS is to build a basic working content management system built around Twitter Bootstrap. This is primarily for personal learning purposes, as I look to better understand how content management systems function.</p>
<p><a class="btn btn-primary btn-large">Learn more »</a></p>
</div>
<!-- Example row of columns -->
<div class="row">
<div class="span4">
<h2>Über Secure</h2>
<p>One of the main goals of this project, aside from basic learning, was to ensure that the design and implementation of all code was safe and secure. For this reason, passwords are securely encrypted using Blowfish, which prevents the password for being decrypted. For this reason, you can be sure that the passwords used with this system, even if leaked online, will be safe and secure.</p>
<p><a class="btn" href="#">View details »</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details »</a></p>
</div>
<div class="span4">
<h2>Register Now!</h2>
<form name="register" action="sections/register/take_register.php" method="POST">
<div class="control-group">
<label class="control-label" for="inputUsername">Username</label>
<div class="controls">
<input type="text" class="span4" id="inputUsername" name="registerUsername" placeholder="Username" required>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
<input type="password" class="span4" id="inputPassword" name="registerPassword" placeholder="Password" required>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</div>
</form>
</div>
</div>
@stop
I know that I will need to modify the route, so I have my app/routes.php
Route::get('/', function()
{
return View::make('public');
});
I also assume, potentially incorrectly, I need to modify my app/controllers/HomeController.php
:
public function showWelcome()
{
$this->layout->content = View::make('public');
}
I know this has to be more simple than it seems to me right now. What am I missing to get the Laravel @yield('content')
to work? Even if you don't want to give me the code, just somewhere where I can learn this or find thorough documentation to help me wrap my head around how this works.
Thank you for your time and assistance.