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 · 651 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 Anna, 1 day ago
2 80 7 hours ago
Support · by gtx, 1 week ago
4 236 2 days ago
Support · by Paul Hodges, 2 weeks ago
13 283 5 days ago
Support · by Anna, 3 weeks ago
9 340 1 week ago
Support · by TomW, 2 weeks ago
4 192 2 weeks ago