Hello,
I am working on a modular page in Grav, and I want the Admin panel to allow reordering of its child modules easily.
Right now, my workaround is to define an array
field in my theme’s blueprint so the editor can manually set header.content.order.custom
as a list.
Blueprint (user/themes/mytheme/blueprints/pages/modular.yaml
):
title: Modular
form:
fields:
tabs:
type: tabs
active: 1
fields:
images:
type: tab
title: Images
(...)
navigation:
type: tab
title: Navigation
fields:
header.content.order.custom:
type: array
value_only: true
Frontmatter (user/pages/01.home/modular.md
):
---
title: Resume
(..)
content:
items: '@self.modular'
order:
by: default
dir: asc
custom:
- _about
- _experience
- _education
- _skills
- _interests
- _awards
---
This works, but it’s not ideal because:
-
If a user adds a new module, they must manually update the array in Admin.
-
They have to type the folder name with the underscore prefix (e.g.
_about
), which is not user-friendly.
I have tried other approaches:
-
Using
type: order
withdata-options@: '\Grav\Common\Page\Page::children'
androute: '@self'
→ always shows the parent’s children, not the current page’s children. -
Using
type: pages
withdefault: '@self.children'
→ just shows an empty text field, not a sortable list.
Question:
Is there a way to create a sortable select field that:
-
Lists the titles of the current page’s children (modules)
-
Stores their folder names in
header.content.order.custom
-
Allows drag-and-drop reordering in Admin?
Any advice or example would be greatly appreciated.
Thanks in advance!