Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Weird behaviour on modular Recent Posts template (Editorial Theme)

Started by Pedro M 3 years ago · 2 replies · 417 views
3 years ago

Hello.
Recently a user alerted me to a bug in the Editorial theme, really strange. When a blog page with a future post date is published, this page is not displayed on the blog until the set post date arrives. However, on the Recent Posts modular page, the same is not the case, showing the future date page.

I've reviewed the recent posts template code and found the following:

If I change the current line

TWIG
{% for p in blog.children.order('date', 'desc').slice(0,limit) %}

it is based on the blog page previously defined in

TWIG
{% set blog = page.find(header_var('blog_url')|defined(theme_var('blog-page'))) %}

{% set limit = page.header.limit|default(3) %}

by the following:

TWIG
{% for p in blog.collection.slice(0,limit) %}

then the page behaves as normal, not showing any future blog posts.

Why is this happening? I have some confusion about the difference between using a collection and children pages

3 years ago

Hi, @pmoreno, you can use blog.children.published.order('date', 'desc').slice(0,limit) in the first case. Read this issue on github, you should probably get some clarification.

👍 1
3 years ago

Hi @b.da

Thanks for the information. I will try your suggestion, although I have finally used the solution above to solve the problem (using the blog.collection)

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by FrViPofm, 14 hours ago
1 29 1 hour ago
Themes & Styling · by stuart young, 1 month ago
3 480 1 month ago
Themes & Styling · by Sebadamus, 2 months ago
5 481 2 months ago
Themes & Styling · by martynfoster735, 2 months ago
1 460 2 months ago
Themes & Styling · by Justin Young, 2 months ago
1 490 2 months ago