Laravel Blade的$loop变量在Sage 9视图中可用吗?

我正在试验Sage WordPress入门主题的版本9, 该主题使用Laravel Blade作为构建WP模板的模板引擎。

我的问题是:Sage 9是否使Blade的$ loop变量在视图的循环内可用?

例如, 给定文件/my_theme/resources/views/archive.blade.php:

1    @extends('layouts.app')
2
3    @section('content')
4      @include('partials.page-header')
5
6      @if (!have_posts())
7        <div class="alert alert-warning">
8          {{ __('Sorry, no results were found.', 'sage') }}
9        </div>
10        {!! get_search_form(false) !!}
11     @endif
12
13      @while (have_posts()) @php(the_post())
14
15      @include('partials.content-'.get_post_type())
16      @endwhile
17
18      {!! get_the_posts_navigation() !!}
19    @endsection

我想在第14行插入以下内容:

@if ($loop->first)
    // Do stuff on first iteration
@endif

但是$ loop是未定义的。

我现在是否缺少某些东西, 或者这是否是Sage 9的限制?


#1


$ loop变量将在@foreach()循环内可用

@foreach ($users as $user)
    @if ($loop->first)
       // This is the first iteration.
    @endif
@endforeach

来源:

https://www.srcmini02.com/65536.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37274.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?