. NET to PHP laraval Framework Learning Series (iv) Project combat---View

Source: Internet
Author: User

The view in the Laravel reference document is a little easier to explain.

The flexibility of view in real-world project development is actually very large.

Let's start by looking at the difference between layout pages in Laravel and ASP.

<! DOCTYPE html>  
<!--this is equivalent to a @section (' title ', false) in ASP.
@section (' title ') <title>{{{$title}}}</title> <!--using {{$title}} is bad here eg:</title>< Script>alert (' hello ') </script>-
<!--here {{{}}} differs from {{}} by transcoding, which does not transcode--@show <meta content= ' Width=device-width, initial-scale=1, MAXIMUM-SC ale=1, User-scalable=no ' name= ' viewport ' > {{html::style (' Vendor/bootstrap/dist/css/bootstrap.css ')}} @section (' Style ') @show <!--HTML5 Shim and respond.js IE8 support of HTML5 elements and media queries-<!--WA RNING:Respond.js doesn ' t work if you view the page via file://-<!--[if Lt IE 9]> <script Src= "Https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js" ></script> <script src= "https://oss.ma Xcdn.com/libs/respond.js/1.3.0/respond.min.js "></script> <! [endif]--> @include (' Shared.header ') <div class= "Container" > {{$main}} </div><!--./wrapper --{{html::script (' Vendor/jquery/dist/jquery.js ')}} {{html::script (' vendor/bootstrap/dist/js/bootstrap.js ')} } @section (' script ') @show </body>

Look at the Post.home code of the home page display list:

<div class= "Row" >  <div class= "col-xs-12 col-sm-6 col-md-8" >  {{$content}}  </div>  <div class= "Col-xs-6 col-md-4" >
<!--This part of the view is a global reference, the view synth in the previous chapter of route.php-- @include (' Shared.sidebar ') </div>< /div>

There is also post.index code Post.index back as a child view will replace {{$content}} in Post.home

@if (!empty ($notFound)) <p>sorry nothing found for your query!</p> @else @foreach ($posts as $post) <article Class= "POST" >

Laravel Frame View This section has many other components, and this chapter code does not refer to other components.

The simple demo is complete and the following is the complete code.


Next, we will look at some of the components commonly used in laravel and apply them to the demo project.

. NET to PHP laraval Framework Learning Series (iv) Project combat---View

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.