Templates
MaplePHP comes with some working examples out of the box, which I will recreate in the guide below, and you can follow along if you want. I will start by showing the three different template types used by MaplePHP and how they can be utilized.
The index template file
The index view is the main index file, and it can contain one view and multiple partials. It also has access to the "Service Provider." MaplePHP comes with a default index file that you can edit according to your needs. The following is the default index file and will be loaded if you do not manually change it, which is possible in your controllers and middlewares.
Let´s take a look at the resources/index.php
file.
The view file
You can only have one view template file at once. It's used for your main content and makes it possible for you to easily change the layout depending on the subject, for example, a blog with a sidebar or regular pages with sections. It does not require much code, and you could add partials directly inside it without any HTML code. However, it is highly recommended that you use it because there will come a time when you will need it. The following is the default view file and will be loaded if you do not manually change it, which is possible in your controllers and middleware.
Let´s take a look at the resources/views/main.php
file.
The Partial files
Partials are used just like the name indicates—it is partial content. This could be navigation, sidebar, header, footer, page content, blog post, and so on. You can add as many partials as you need. Below, I will show you one of the pre-installed examples.
Let´s take a look at the resources/partials/ingress.php
file.
Last updated