laravel template yeild use

不言
Release: 2023-03-24 19:30:01
Original
1794 people have browsed it

<br/>
Copy after login

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. <br/>So, I carefully checked laravel's template usage instructions, and it turned out to be very powerful. <br/> Let’s go directly to my solution. <br/> 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
Copy after login

2. Single page code:

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

                                                                         

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template