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.

General

How to order a page collection by a field in a list

Started by Thomas Green 8 years ago · 0 replies · 511 views
8 years ago

I am using the list field-type for the parts of a name, and I wish to list the data ordered by the second field of the first item. (Say I have books by Jane Doe, by John Smith, and a two-author book by A. Nother and Yetan Other. I want to list them in the order Doe, Nother, Smith.) So my blueprint yaml will be like this:
header.authorname:
type: list
fields:
.authorname_part_1:
type: text
.authorname_part_2:
type: text

What do I put in the front matter for the collection? I thought it might be something like this, but that doesn't work:
content:
items: '@self.children'
order:
by: header.authorname[0].authorname_part_2
dir: asc
(Sorry, the indenting seems to have got lost, I don't quite know how this editor works)

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 80 10 hours ago
General · by pamtbaau, 15 hours ago
1 51 15 hours ago
General · by Andy Miller, 1 day ago
0 45 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago