Content order custom

While doing some tests I discovered that if you specify ordering in the first line of the loop() macro in navigation.html.twig:

{% for p in page.children.visible.order('custom', '') %}

and set content.order.by: custom and nothing else regarding the ordering in your parent page frontmatter or header like:

---
title: Team
content:
    items: '@self.children'
    order:
        by: custom
        custom:
            - dafne-maria-fiedler
            - deborah-klein
            - sylke-hannasky
            - theresa-hoerl
            - maik-toedter
            - christoph-bernhard
            - kathrin-schlosser
            - nora-jensen
            - frank-asmis
---

then the submenu will show your subpages in the order specified.

Unfortunately this is not the solution (keep on reading though!) because now a custom order is used for all pages even if there is no custom order specified. So Grav does not fall back to the default behaviour set in System configuration.

FWIW During my experiments I got completely lost in the documentation. Even though the order is set when I add the following code to the base.html.twig template file:

<div>
{{ dump(page.orderBy) }}
{% for p in page.collection %}
    {{ p.title }}
{% endfor %}
</div>

the Grav Debug bar reports that orderBy is default however the list of page titles is in the required order.

At some point (and now things get exciting) I decided to experiment with the value of the order_manual frontmatter variable.

For my three pages test case I set this frontmatter:

---
title: Team
content:
    items: '@self.children'
order_manual:
    - bravo
    - charlie
    - alpha
---

And that is all there is to it!

There is no need for a modified navigation.html.twig template and there is no need to use content.order.by in the frontmatter.

Don’t ask me why. I can’t see or understand the logic. Looking at the Page.php code didn’t help much with that.