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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

How to order a blog list by a header field?

Started by ian russell 8 years ago · 2 replies · 930 views
8 years ago

More help please. I am trying to order a blog list by a header field.

Option 1.
I have 'brand:' in the header so tried:

YAML
    order:
        by: header.brand

Result:

TXT
Validation failed: 
Invalid input in "Order By"

Maybe as 'brand;' is page specific?

Option 2
I also have brand in the taxonomy but this produced the same result:

YAML
        order:
            by: header.taxonomy.brand

GRAV documentation says:

header.x The order based on any page header field. i.e. header.taxonomy.year. Also a default can be added via a pipe. i.e. header.taxonomy.year|2015

What am I missing?

Thank you

Ian Russell

last edited 07/11/18 by ian russell
8 years ago

The first one seems fine. The second, I think, won't give you what you want anyway.

Is brand at the top level of your YAML frontmatter hierarchy?

Does every page in the collection you are ordering have this header? If not, maybe try adding a default with a pipe as mentioned in the docs in your quote.

8 years ago

Thank you, hughbris.

In the end, using the Gantry admin pages without delving into the twig I could only get order: by: title to work ; folder behaved like default with numeric prefixes still attached.

I will think about storing all the pages in question without numeric prefixes and adopting a folder naming scheme to order the pages.

FWIW I echo a previous comment about the documentation being hard to follow in this area (how-to example needed for each option): /forum/content-markdown/content-order-custom-t3296

Ian Russell

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 10 hours ago
Support · by Anna, 3 days ago
2 60 13 hours ago
Support · by Justin Young, 14 hours ago
1 30 14 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago