我想检查一下是不是循环的最后一篇文章。我正在使用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" }}赋值给变量呢?如何给变量赋值?
发布于 2013-07-11 20:59:42
实际上还有一种更简单的方法;streams核心代码将last属性添加到数组中的最后一项- source code -您只需使用条件查询:
{{ 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 }}此外,正如Nick指出的那样,您可以拥有多个计数器。
https://stackoverflow.com/questions/17397501
复制相似问题