Reputation: 569
Dear stackoverflowers,
First of all I would like to inform you that I'm new to laravel 4, so if I'm making a fool out of myself by asking this question, then so be it..
I've set up a project and want to use templates. I have these folders/files so far:
--views
----home
------home.blade.php
------login.blade.php
----layouts
------master.blade.php
I have a get-route that makes a new view to 'home.home', which contains following code:
@extends('layouts.master')
@section('content')
{{-- zet via TAB om naar h1 met klasse 'subheader'
h1.subheader --}}
<div class="panel">
<div class="page-header">
<h1>Startpagina</h1>
</div>
@if(Auth::Guest())
@yield('login')
@else
@endif
</div>
@stop
Now I want to make another template, which would function as a partial view (this could also be header, footer, ..., but for now its the login form). I thought this would've done the trick, but obviously it doesnt...
@extends('layouts.master')
@section('login')
<p>Login form comes here</p>
@stop
Any suggestions? Thanks in advance.
HS.
Upvotes: 2
Views: 1596
Reputation: 5387
Instead of the @extends
statement in your login file, you should include it as a file in the home (and all views where you want it to appear)
Try:
@if(Auth::Guest())
@include('login')
@else
@endif
and remove the @extends('layouts.master')
, @section('login')
and @stop
in the login view itself.
All variables that exist in your home view will also be available in your login view.
In case you want the login form to act as a partial which operates with its own logic (or it needs additional data), you should consider using view composers
Upvotes: 1