Give Child Pages Custom Order

My problem is that I’m attempting to give the child pages in my portfolio a custom order, but my code is not working.

Here’s the code I’m using:

title: Portfolio
content:
    items: '@self.children'
    order:
        by: default
        custom:
            - _celebrity-interviews
            - _essays
            - _video
            - _one-direction-connection

For some reason, though, the pages are still appearing in the order I created them. Does anyone know where I went wrong?

Thanks!

Hi - try '@self.modular', as @self.children selects all non-modular children. Those look awful modular :slight_smile:

1 Like

Tried this fix, but it broke the page. Here’s what the page looks like, if it helps: http://noelledevoe.com/portfolio (Note, I hacked the ordering by giving each page a date and then ordering by date)

But actually, this brings up a good question: What is the difference between modular pages and non-modular pages.

These pages are set up as direct children to the Portfolio page, but what would make it modular vs. non-modular. Because I certainly didn’t set any option for the page to be considered modular. This is a concept I’ve been struggling to understand, haha.

In any case, thanks for the suggestion! :slight_smile:

Ah, the link helps. To my mind, modular pages differ from child pages in that they are merely parts of pages and never discreet pages that can be displayed/routed on their own. Your pages are child pages because they have their own URLs, as I can see.

The underscore prefix means Grav is going to treat them as modular pages, which might have caused your recent breakage - can’t be sure.

You could simply use the “default” order now since your child pages now require a numeric prefix to be routable (01.celebrity-interviews etc).

There is some overlap between modular and plain child pages, and with hacks you can probably make each of them behave like the other. I don’t feel like I have enough authority or grasp on the real intended differences to answer your question at the conceptual level. I am going to ask others to pitch in! My understanding has developed innately based on what has worked and fitted in practice :slight_smile:

Hope that helps!

Hi nellygrl,
there is a thread about modular pages:

What’s the purpose of modular pages at all?

Hope it’s usefull.

The docs outline this concept fairly clearly at https://learn.getgrav.org/content/modular. @hughbris is correct in saying that child pages are regular pages in every regard, just situated in the hierarchy of pages. Modulars, distinctly, are not. Modulars do not have child pages, it has modules, which are exclusively meant for modular use within a modular. Importantly, modules are still content, not layouts or expressions of logic like partial templates.

Per the docs, at https://learn.getgrav.org/content/modular#setting-up-the-primary-page, you should do what Hugh suggest and use '@self.modular' when ordering modules in a modular. We can infer from the underscore prefix on the folder names that these are modules, not pages. A modular does not use numeric prefixes or dates, only an underscore.

Hope it’s usefull :mask: