0

我想检查是否是循环的最后一个帖子。我正在使用 pyroCMS。但问题是,如果我使用helper:count两次,它就不能正常工作。我如何分配helper:count给变量并使用以后的变量。这可能吗?

{{ blog:posts limit="5" order-by="title" order-dir="desc" }}

{{ if { helper:count mode="subtract" } == blog:all_posts}}

                <li>
                    <a href="{{ url }}" title="Read more about: {{ title }}">
                    <span class="naslovna_datum_novice">{{ helper:date format="d.m.Y" timestamp=created_on }} - </span>
                        {{ title }}
                    </a>
                </li>

                {{ elseif { helper:count mode="subtract" } == 5 }}

                <li>
                    <a href="{{ url }}" title="Read more about: {{ title }}">
                    <span class="naslovna_datum_novice">{{ helper:date format="d.m.Y" timestamp=created_on }} - </span>
                        {{ title }}
                    </a>
                </li>

                {{ else }}

                <li class="pikce_spodaj">
                    <p>
                        <a href="{{ url }}" title="Read more about: {{ title }}">
                        <span class="naslovna_datum_novice">{{ helper:date format="d.m.Y" timestamp=created_on }} - </span>
                        {{ title }}
                        </a>
                    </p>
                </li>   

                {{ endif }}

{{ /blog:posts }}   

那么如何分配{{ helper:count mode="subtract" }}给变量?如何将任何东西分配给变量?

4

1 回答 1

2

实际上有一个更简单的方法;流核心代码将last属性添加到数组中的最后一项 -源代码- 您可以使用条件查询:

{{ if last }} foo {{ endif }}

(这样做的源代码是

这是我刚刚测试过的博客的一个工作示例:

{{ blog:posts limit="5" order_by="title" }}
    <h2>{{ title }}</h2>

    [...]

    {{ if last }}<p>This is the last item</p>{{ endif }}
{{ /blog:posts }}

此外,正如尼克指出的那样,您可以拥有多个柜台。

于 2013-07-11T12:59:42.390 回答