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

Twig Help

Started by Muut Archive 9 years ago · 2 replies · 433 views
9 years ago

I have so far failed to find any documentation on the twig functions and filters that appear to be custom in Grav. More specifically order() which I have found among the twig recipes, but can't successfully modify to order by anything else but date.
I am seeking to order listed post by some custom page header. Ideally.
Thanks.

9 years ago

In addition to all of Twig's default filters and functions, Grav's are listed here. Themes have an extended set, including orderBy, is that what you are applying, or is the order set through FrontMatter?

9 years ago

Hi Daniel, order is not a Twig filter but a method of the class.

What page.find('/blog').children.order('date', 'desc').slice(0, 5) does is:

  1. call the Grav Page object's find method to return a page
  2. call that page children
    method, which returns a Collection object
  3. call the order method on the Collection object, which still returns a collection
  4. slice the collection

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1323 9 years ago
Archive · by Muut Archive, 9 years ago
2 920 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2924 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago