Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Weird behaviour on modular Recent Posts template (Editorial Theme)

Started by Pedro M 3 years ago · 2 replies · 295 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 Pedro M, 2 months ago
4 197 2 months ago
Themes & Styling · by Ian, 2 months ago
3 92 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 454 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 47 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 127 3 months ago