Common template of laravel framework template inheritance including implementation method analysis

  • 2021-12-19 06:14:07
  • OfStack

This article describes the laravel Framework Template Common Template, Inheritance, Inclusion Implementation Method. Share it for your reference, as follows:

Introduction:

Use laravel framework to develop background management system or web site, that is, embedded development, so php developers have to integrate templates themselves.

This article gives an example of background management system

Template path:/resources/views/admin

1. Create a public directory

/resources/views/admin/layouts/

Under layouts, the following templates are established (which can be reduced or increased by themselves)

/header. blade. php header
/main. blade. php body core area
/sidebar. blade. php Sidebar
/footer. blade. php Foot
/error. blade. php prompt section

Here are examples of the contents of the above templates:

header.blade.php


<header>
 xxxxxx
 <p> Log out of the login </p>
</header>

main.blade.php


<!DOCTYPE html>
<html>
 <head>
  <title>@yield('title')</title>
  <link rel="stylesheet" href="">
 </head>
 <body>
  @include(admin.layouts.header) // Include headers 
  @include(admin.layouts.sidebar) // Include sidebar 
  <div>
  @yield("content")  // Designated block 
  </div>
  @include('admin.layouts.footer') // Include tail 
 </body>
</html>

sidebar.balde.php


<aside>
 <li></li>
</aside>

Here is how one other normal template would be written:

For example:

index.blade.php


@extends("admin.layouts.main") // Inheritance 
@section('title',' List of articles ') // Fill in the title 
@section("content") // Fill in area content 
 <div></div>
@endsection

The above is a summary in the process of doing the project

For more readers interested in Laravel related content, please check the topics on this site: "Introduction and Advanced Tutorial of Laravel Framework", "Summary of Excellent Development Framework of php", "Introduction Tutorial of php Object-Oriented Programming", "Introduction Tutorial of php+mysql Database Operation" and "Summary of Common Database Operation Skills of php"

I hope this article is helpful to the PHP programming based on Laravel framework.


Related articles: