Home >Backend Development >PHP Tutorial >laravel template yeild use

laravel template yeild use

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

<br/>

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 :

<p class="head-tips">@yield(&#39;title&#39;)</p><p class="jump-to-regist">#获取当前页面路由,判断是否是登陆页面
@if (Request::path()==&#39;login&#39;)
    没有账号?    <a href="{{ url(&#39;register&#39;) }}">去注册</a>@else
    已有账号?    <a href="{{ url(&#39;login&#39;) }}">去登陆</a>@endif

2. Single page code:

@section(&#39;title&#39;, &#39;关于我们&#39;)

                                                                         

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