Concatinating Views in Laravel

- 1 answer

Ad

I'm studying Laravel, and I want to know how to concatinate multiple views together.

I've looked through the documentation on laravel.com and can't find the section that tells me how to concatinate views.

I've solved the problem like this (in my controller):

public function showPage() {
    return View::make('header') . View::make('content') . View::make('footer');
}

But surely there is a better/correct way... I would appreciate any help.

Ad

Answer

Ad

You can load do something like this

public function showPage() {
    return View::make('page');
}

And in your page.blade.php:

@include('header')
@include('content')
@include('footer')

But actually it would be better to have this structure.

layout.blade.php:

@include('header')

@yield('content')

@include('footer')

page.blade.php:

@extends('layout')

@section('content')
     HTML of content here...
@stop
Ad
source: stackoverflow.com
Ad