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.
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...