Php 如何在laravel中包含扩展布局文件?
我很难根据if-else条件扩展到不同的布局文件Php 如何在laravel中包含扩展布局文件?,php,laravel,php-7.2,laravel-6.2,Php,Laravel,Php 7.2,Laravel 6.2,我很难根据if-else条件扩展到不同的布局文件 @if($subdomain_alias === "blk") @extends("layouts.frontend-new") @section('title') Home @endsection @section('content') {{-- Some Content --}} @endsection @else @extends('l
@if($subdomain_alias === "blk")
@extends("layouts.frontend-new")
@section('title')
Home
@endsection
@section('content')
{{-- Some Content --}}
@endsection
@else
@extends('layouts.frontend')
@section('title')
Home
@endsection
@section('content')
{{-- Some Content --}}
@endsection
@endif
但问题是布局都包括在内,我可以看到所有东西两次
我试着使用@include,但没有在其中加载视图内容。
您可以看到标题两次
有人能帮我吗?我想出来了,我刚刚把条件和布局分开了
@extends(($subdomain\u alias==“blk”)?“layouts.frontend new':“layouts.frontend”))
用于包括不同的布局,并为各部分使用单独的if-else。您需要使用三元运算符在刀片文件第一行的不同主布局之间进行选择:
@extends(($subdomain_alias === "blk" ? "layouts.frontend-new" : "layouts.frontend"))
@section('title')
Home
@endsection
@section('content')
{{-- Some Content --}}
@endsection
这回答了你的问题吗?不,我想包括不同内容的不同布局文件。