Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Ordering pages by custom header variable in Twig

Started by P. Fighter 8 years ago · 2 replies · 743 views
8 years ago

Example: I want to find all pages with the tag foobar, but I want to order them alphabetically based on a custom header variable.

Right off the bat, my first try would be the following:

TWIG
{% for page in taxonomy.findTaxonomy({'tag':'foobar'}).orderBy('header.custom_order') %}

But that returns nothing. Suggestions?

last edited 04/12/18 by P. Fighter
8 years ago

No cigar. Also, it's a string in the docs. - This couldn't possibly refer to the variable in the fetched pages as it would represent a variable itself, even if it's not declared (then we'd just pass null to the function orderBy, no?)

Suggested topics

Topic Participants Replies Views Activity
Support · by stell, 1 week ago
5 246 4 hours ago
Support · by gravinator, 1 month ago
5 460 6 hours ago
Support · by Gravver, 2 weeks ago
6 281 1 week ago
Support · by Marcel, 4 weeks ago
2 338 1 week ago
Support · by blu3prince, 2 weeks ago
1 256 2 weeks ago