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

For loop order by date

Started by Muut Archive 11 years ago · 4 replies · 435 views
11 years ago

Is it possible to render pages with a {% for lil_foo in foo.children %} in date order, like newest to oldest?

11 years ago

Yup, it's just:

TWIG
{%for lil_foo in foo.children.order('date', 'desc') %}
11 years ago

ok, next level.. what if i need to return all the second level child of a page with a for loop in date order.. ? :/

11 years ago

your going to have to put another loop in side that first loop. have a look at the macro in the partials/navigation.html.twig in the Antimatter theme to see how you can do this recursively.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 2281 9 years ago
Archive · by Muut Archive, 9 years ago
2 1496 9 years ago
Archive · by Muut Archive, 9 years ago
2 4745 9 years ago
Archive · by Muut Archive, 9 years ago
1 3562 9 years ago
Archive · by Muut Archive, 9 years ago
3 1621 9 years ago