-
-
Notifications
You must be signed in to change notification settings - Fork 351
Open
Description
Hello there! So I came across a bug - even when the articles have the same date, "archive" template will create an separate <dt> block for each of them anyway. For example:
01.01.2025
Article 1
01.01.2025
Article 2
When it should be as follows:
01.01.2025
Article 1
Article 2
As far as I can tell, the problem is in this line of code:
{% set previous_date = article.locale_date %}
set wont pass the variable value across the "for" loop. For that purpose the "namespace" should be used:
{% extends "base.html" %}
{% block title %} – {{ _('Archives') }}{% endblock %}
{% block content %}
<article class="single">
<header>
<h1 id="archives">{{ _('Archives') }}</h1>
</header>
<div>
<dl>
{% set ns = namespace(previous_date=False) %}
{% for article in dates %}
{% if article.locale_date != ns.previous_date %}
{% set ns.previous_date = article.locale_date %}
<dt>{{ article.locale_date }}</dt>
{% endif %}
<dd>
<a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a>
</dd>
{% endfor %}
</dl>
</div>
</article>
{% endblock %}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels