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

Inline ordering

Started by Muut Archive 9 years ago · 7 replies · 403 views
9 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.

9 years ago

Try this:

TWIG

{% set posts = page.find('/blog/posts').children.order('date', 'desc') %}
---
9 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' ?!

9 years ago

Try swapping 'date' with 'timestamp'.

TWIG

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

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

I chose: publish_date ... and it works.

9 years ago

nevertheless, thanks for your advice, @robbinfellow !!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1334 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2938 9 years ago
Archive · by Muut Archive, 9 years ago
3 1111 9 years ago