您好我是laravel的新手,無法理解sections
,但我試圖在循環中只顯示一次特定的一次,然後重複其他所有操作,如果一定的條件是真的。這是我想修改的代碼。在這裏,我評論了我只想要一次的那一行。在@foreach循環中顯示一個@section
@foreach ($pageTypes['news-events']->categories as $cat)
<?php $related = $page->relatedPages($pageTypes['news-events']->id, $cat->id); ?>
@if ($related->count() > 0)
@section('tab-titles')
//i want to display this LI once if true
<li class="tab first"><a href="#news" title="insight">Insight</a></li>
@append
@section('news-content')
<div id="news" class="tabs_text">
<h2>{{ strtoupper($cat->name) }}
</h2>
<ul>
@foreach($related as $news)
<li><a href="{{ url($news->url) }}" title="{{ $news->title }}">
{{ $news->title }}
</a>
</li>
@endforeach
</ul>
</div>
@append
@endif
@endforeach