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

Ordering pages by custom header variable in Twig

Started by P. Fighter 8 years ago · 2 replies · 678 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 Paul Hodges, 4 weeks ago
19 484 5 days ago
Support · by Lauw, 7 days ago
2 99 7 days ago
Support · by Anna, 3 weeks ago
4 426 1 week ago
Support · by gtx, 4 weeks ago
4 377 3 weeks ago
Support · by Anna, 1 month ago
9 484 3 weeks ago