From 16f30cbd3625c621eb79615c7e3dcfe6483af276 Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Wed, 20 Apr 2022 19:52:54 +0000 Subject: [PATCH] Add different numbers of related posts in different screen sizes --- fet2020/posts/views.py | 2 +- .../posts/partials/_posts_related.html | 8 +++++++ fet2020/templates/posts/show.html | 23 +++++++++++-------- 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 fet2020/templates/posts/partials/_posts_related.html diff --git a/fet2020/posts/views.py b/fet2020/posts/views.py index 6fc251fc..27549498 100644 --- a/fet2020/posts/views.py +++ b/fet2020/posts/views.py @@ -182,7 +182,7 @@ def show(request, id=None): "author_image": author_image, "next": __next(post, public_only), "previous": __previous(post, public_only), - "related_posts": related_posts[:3], + "related_posts": related_posts[:4], "ep_agenda_link": ep_agenda_link, "ep_protocol_link": ep_protocol_link, "filename_agenda": filename_agenda, diff --git a/fet2020/templates/posts/partials/_posts_related.html b/fet2020/templates/posts/partials/_posts_related.html new file mode 100644 index 00000000..e3ceab6c --- /dev/null +++ b/fet2020/templates/posts/partials/_posts_related.html @@ -0,0 +1,8 @@ +
+

{{ post.title|safe }}

+ + + + {{ post.date|date:"d. F Y" }} + +
diff --git a/fet2020/templates/posts/show.html b/fet2020/templates/posts/show.html index eabde158..af56c771 100644 --- a/fet2020/templates/posts/show.html +++ b/fet2020/templates/posts/show.html @@ -315,16 +315,19 @@

Weiterlesen

{% for post in related_posts %} - -
-

{{ post.title | safe }}

- - - - {{ post.date|date:"d. F Y" }} - -
-
+ {% if forloop.counter0 == 2 %} + + {% elif forloop.last %} + + {% else %} + + {% include 'posts/partials/_posts_related.html' %} + + {% endif %} {% endfor %}