Home  >  Article  >  Backend Development  >  laravel template yeild use

laravel template yeild use

不言
不言Original
2018-04-24 15:55:451657browse


Today I encountered a small problem related to templates. Different titles need to be displayed on different pages, and different hyperlinks need to be displayed according to routing.
So, I carefully checked laravel's template usage instructions, and it turned out to be very powerful.
Let’s go directly to my solution.
Define a yeild in the template. When other pages inherit, dynamic content will be passed into this designated area:

1. Code in the template :

@yield('title')

#获取当前页面路由,判断是否是登陆页面 @if (Request::path()=='login') 没有账号? 去注册@else 已有账号? 去登陆@endif

2. Single page code:

@section('title', '关于我们')

                                                                         

The above is the detailed content of laravel template yeild use. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn