我希望能够在一个模板中循环遍历过去的事件:
{% for page in m.search[{past cat='event'}] %}
{% if forloop.first %}<ul>{% endif %}
<h2>{{ m.rsc[page].date_start|date:"M j, Y" }} {{ m.rsc[page].title }}</h2>
<p>{{ m.rsc[page].body|show_media }}</p>
<p><a href="{{ m.rsc[page].website }}">Register to attend this event.</a></p>
{% if forloop.last %}</ul>{% endif %}
{% endfor %}基本上,我正在寻找一个过去的搜索类型,它与即将到来的搜索类型相反。
我已经可以得到即将到来的活动如下:
{% for page in m.search[{upcoming cat='event'}] %}
{% if forloop.first %}<ul>{% endif %}
<h2>{{ m.rsc[page].date_start|date:"M j, Y" }} {{ m.rsc[page].title }}</h2>
<p>{{ m.rsc[page].body|show_media }}</p>
<p><a href="{{ m.rsc[page].website }}">Register to attend this event.</a></p>
{% if forloop.last %}</ul>{% endif %}
{% endfor %}如果我被指向正确的方向,并且我将把结果贡献给主代码库,我就不会对此进行编码。
如何在Zotonic模板中的搜索中遍历过去的项目?
发布于 2010-10-23 11:02:13
您可以使用查询搜索模型的date_start_before术语,虽然我确实发现它查看了search_query.erl中的源代码(第293行),但它显然是没有文档的。
尽管我认为您的查询应该检查pivot_date_end,而不是pivot_date_start。
为了使这更容易访问,您可以向mod_search.erl模块中添加一个处理程序(非常类似于mod_search.erl),最后还可以修改
mod_search模块实现了大多数搜索。
另见http://zotonic.com/documentation/761/the-query-search-model
欢迎补丁程序:-)
https://stackoverflow.com/questions/3998776
复制相似问题