Any site has pages. These pages might contain simple, static information like pictures and text or it might contain dynamic information from a database. In this section we will cover how to create simple pages, complex pages, pages that nobody can see. Let's get started.
So, if you are new to Laravel or new to the concept of routing you will want to read this: A route is how you, the developer, instruct the system where to go when a user requests a url or submits data to a url.
So, a route is usually similar to one of these examples: - beerzrule.com/top-10-beers: When a user goes to this page the route returns the HTML needed to draw out the beer list. In simple terms, it accomplishes this by mapping the route's url to a view file which is located in the "/resources/views/" directory. - beerzrule.com/add-new-beer: This url gets called when a user submits the "Add New Beer" form which puts it into the database.
There are other things routes can return, but for now just think of it as routes that return HTML and routes that receive and process data.
'Page' vs. 'Route'
Keep in mind that a 'page' in Devise is a route. You can interchange the terms 'page' and 'route' in context of Devise. They are the same. We decided to use the term 'Page' because we felt our customers would understand more easily. You're a developer. Man / Woman up.
If you're coming from the Laravel world you're probably familiar with routing and how it works in good 'ol Laravel. Devise works alongside the Laravel routing engine by simply bootstrapping our routes stored in the database.
This allows you to still use the routes.php file or however you have done routing in the past alongside Devise.
About Laravel 5
With the launch of Laravel 5, we have fully implemented the route caching system into Devise to help accelerate load times and reduce queries.
Creating a page is easy. From the administration dashboard click on ahem... Pages. Click on 'Create New Page' in the top right-hand corner and you will be presented the Create A New Page form.
Title of the page: The purpose of this field is to supply a label for the administrative list of pages. It really isn't meant for anything on the front-end.
Short description of the page: A place to put any notes about what this page is and what its purpose is.
Language: This is the language of this page. We'll go more into languages in another section.
View Template To Use: Templates are layouts you have placed in your
app/view/templates directory. You can read more on how templates work in the templates section of the documentation.
Page Slug: The page slug is the url of the page. You can structure these however you like. So our breweries list page could be
/breweries/list. Structure your pages however you see fit. What if it's a view that is a little more complex like a page that shows the details of a specific brewery? Then you might do something like this:
That allows you to set a url parameter we can use to load the appropriate brewery.
Publish on Save: This will make the page live when it is created.
Show Advanced Options: When toggled you get to see all the goodies!
Meta Title: This is the title that will populate the
<title> of the template.
Meta Description / Meta Keywords: These are used to populate their respective meta tags.
Note that the meta fields, head code, and footer code must be inserted correctly in the templates your site uses. They don't just magically appear. See the templates documentation to see how this should be formatted.
Administration Page: Will this page be visible on the admin pages index.
Before: A function which will be executed "before" the actual page request. An example would be if the user needs to be in the administrators group, we could execute a function to check every user's group upon page request.
There are essentially two things you can do with a page once it has been created:
Page versions are simply instances of a page. If a page is the URL itself the page version is the content on that page. You can find the page versions of a page by clicking Expand page versions under the title of each page on the page index of administration.
One of the things that we, as developers, need to do is have our customers review new layouts and content without having it published for the public to see. Devise makes this very easy to do. From the pages index find the page that you wish to share. Click Expand page versions under the page title to show the page versions.
The calendar gives you and your customers a great way of seeing when page versions will be published and which pages need to go live. To manage when pages go live you can either drag them around the calendar or click on any page version and edit their start or end time in the modal window.
If you wish to remove a published page version from the calendar click on the entry and uncheck the published checkbox.