问题描述
根据if else条件,我很难扩展到不同的布局文件
@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
但是问题是布局都包括在内,而且我可以看到所有内容两次。
您可以看到标题两次。
有人可以帮我吗?
解决方法
我想通了,我只是将条件与布局分开了。
@extends((( $subdomain_alias === "blk") ? 'layouts.frontend-new' : 'layouts.frontend' ))
将其用于包含不同的布局,并在各部分分开(如果其他则分开)。
,您需要使用三元运算符在刀片文件第一行的不同主布局之间进行选择:
@extends(($subdomain_alias === "blk" ? "layouts.frontend-new" : "layouts.frontend"))
@section('title')
Home
@endsection
@section('content')
{{-- Some Content --}}
@endsection