2016-05-19 4 views
0

私は以下のコードを持っていました。サブビューで異なるレイアウトを拡張できますか?

@if(isset($is_gift_card_site) && $is_gift_card_site) 
    @extends('gift_card.layout.index') 
@else 
    @extends('layout.index2') 
@endif 

@section('content') 
    //html 
@stop 

これは機能します。しかし、それは両方のレイアウト(複製)を拡張します。この問題の解決策。どうもありがとう。

答えて

1

三項演算子を試しましたか?

@extends(isset($is_gift_card_site) && $is_gift_card_site ? 'gift_card.layout.index' : 'layout.index2') 

または変数を持つ:

<?php $layout = isset($is_gift_card_site) && $is_gift_card_site ? 'gift_card.layout.index' : 'layout.index2'; ?> 
@extends($layout) 
+0

もう一度確認してください。それは動作しません。それは重複しませんが、常に 'gift_card.layout.index'を拡張します。 –

+0

これを試してください: '<?php $ layout = isset($ is_gift_card_site)&& $ is_gift_card_site? 'gift_card.layout.index': 'layout.index2'; ?> ' ' @extends($ layout) ' – TheFallen

関連する問題