[英]pyrocms assign count to variable
我想检查是否是循环的最后一篇文章。 我正在使用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" }}
分配给变量? 如何为变量赋值?
实际上有一种更简单的方法; 流核心代码将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 }}
此外,正如尼克指出的那样,你可以拥有多个计数器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.