Loading a view into another view/nested views
Very often, our web pages will have a similar layout and HTML structure. To help separate out the repeated HTML, we can use nested views in Laravel.
Getting ready
For this recipe, we need to have completed the Creating and using a basic view recipe.
How to do it...
To complete this recipe, follow these steps:
In the
app/view
directory, add a new folder namedcommon
.In the
common
directory, create a file namedheader.php
and add the following code to it:<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>My Website</title> </head> <body>
In the
common
directory, create a file namedfooter.php
and add the following code to it:<footer>© 2013 MyCompany</footer> </body> </html>
In the
common
directory, create a file nameduserinfo.php
and add the following code to it:<p>You are <?= $my_name ?>, from <?= $my_city...