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

Inline ordering

Started by Muut Archive 10 years ago · 7 replies · 516 views
10 years ago

I want to order the output of:

TWIG
{% set posts = page.find('/blog/posts').children %}

how can I order the children by header.date (a separate field in my page-frontmatter) descending ?

thank you.

10 years ago

Try this:

TWIG

{% set posts = page.find('/blog/posts').children.order('date', 'desc') %}
---
10 years ago

thanks. but it seems that the first parameter is skipped during rendering process, only the default order is being kept. at least 'desc' seems to work.

my frontmatter now looks like this:

TXT
timestamp: '2017-02-21T18:20'

how can I choose to take the timestamp-field instead of 'date' ?!

10 years ago

Try swapping 'date' with 'timestamp'.

TWIG

{% set posts = page.find('/blog/posts').children.order('timestamp', 'desc') %}
---
10 years ago

changing the variable-name in the front-matter finally has helped.

I chose: publish_date ... and it works.

10 years ago

nevertheless, thanks for your advice, @robbinfellow !!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 2280 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 3559 9 years ago
Archive · by Muut Archive, 9 years ago
3 1621 9 years ago