Content order custom

Hello,

I am just working on a new Site on which a collection should loop over several child pages.

My first approach to give those childs a custom order was to add the numeric prefix to the folder name - and it worked as expected.
But i noticed, that the ordered childs now appeared as a submenu (child-theme extending Quark) and decided to order the items as suggested at https://learn.getgrav.org/content/collections

my frontmatter now looks like:

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

but for some reason the ordering is just alphabetical (the pages do not have custom slugs - it is just the foldernam)
even the

admin:
    children_display_order: collection

worked in the admin panel.

any hints on what i missed ?

Thank you in advance

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.

I should have mentioned that the subpage folders are named:

01.alpha
02.bravo
03.charlie

It does not matter but for completeness: Only the default.md file of the page “alpha” has a title set in it’s frontmatter. The other two pages do not have any frontmatter.

Thank you for investigating the problem!

for some reason using order_manual did not change anything.
Only if i name the folder with a numerical prefix the pages appear as set - but this is still the order they appear at the fs.
this would be ok for me if the pages would not appear as submenu items at the menu. Is there a way to set this per page? so i could tell the collection not to insert the childs as submenu entries

you were right - i had a typo in the frontmatter.
using order_manual worked perfect

Thank you very much!

Regards
Odde