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 · 640 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, 7 days ago
13 226 21 hours ago
Support · by gtx, 4 days ago
2 132 3 days ago
Support · by Anna, 2 weeks ago
9 305 4 days ago
Support · by TomW, 2 weeks ago
4 171 7 days ago
Support · by Anna, 2 weeks ago
4 178 1 week ago