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

For loop order by date

Started by Muut Archive 11 years ago · 4 replies · 336 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 1338 9 years ago
Archive · by Muut Archive, 9 years ago
2 927 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2941 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago