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 · 590 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 BenLaKnet, 6 days ago
1 129 3 days ago
Support · by BenLaKnet, 1 week ago
5 199 3 days ago
Support · by kskt, 3 days ago
0 58 3 days ago
Support · by David Meissner, 3 days ago
0 54 3 days ago
Support · by David Meissner, 4 days ago
3 99 3 days ago