首页 > 解决方案 > 如果显示特定页面,如何包含特定文件

问题描述

我想添加 layouts/frontend.blade.php

根据页面包含不同的 seo.blade.php 文件。

@if (page == 'home')
   @include('partials.seo')
@endif

@if (page == 'about')
  @include('partials.seo2')
@endif

我该怎么做?

标签: phplaravel

解决方案


您可以使用分段:

@if (request()->segment(0) == 'home')
   @include('partials.seo')
@endif

@if (request()->segment(0) == 'about')
  @include('partials.seo2')
@endif

推荐阅读