我的一个手工艺项目,我有文章,一旦单击文章,我就可以阅读那些文章,在右边的内容中,我有一个选项卡调用下一篇文章,但是单击时没有任何反应 这里是实时网站-http://ambitmagazine.co.uk/poems/ambit-poetry-competition-2018
屏幕截图-https://prntscr.com/o9gkph
_entry.html
{% extends "_layout" %}
{% block content %}
{% set issue = entry.issue.first() %}
{% set nextArticle = craft.entries.section('articles').after(entry.postDate).order('postDate asc').limit(1).find() %}
<div class="article section{% if entry.largeText %} article--larger-text{% endif %}">
<div class="article__inner section__inner">
{% include 'articles/_partials/article-header' with { article: entry, issue: issue } only %}
{% include "articles/_types/" ~ entry.type %}
{% if entry.relatedAuthor|length > 0 %}
{% include 'articles/_partials/article-footer' with { article: entry } only %}
{% endif %}
{% if nextArticle|length > 0 %}
<div class="next-item">
<a href="{{nextArticle[0].url}}" class="next-item__inner">
<span><strong>Next Artcile</strong></span>
<span>\</span>
<span>{{nextArticle[0].title}}</span>
</a>
</div>
{% endif %}
<div class="article__sidebar-inner"></div>
</div>
<div class="article__sidebar-outer"></div>
</div>
答案 0 :(得分:0)
.after
正在执行> =操作,因此当前文章已包含在结果中,并且几乎肯定会成为第一个选择。
执行类似.after(entry.postDate|date_modify('+1 second'))
的操作会排除当前文章,并会为您提供所需的内容。
对于您的查询来说,保持时间不变可能会更清楚,但通过ID明确排除当前条目:
{% set nextArticle = craft.entries()
.section('articles')
.after(entry.postDate)
.id(['not', entry.id])
.order('postDate asc')
.one() %}