Dynamic sortBy value in sections

I configured a blueprint called blog which can have many sub-pages with the blueprint post. Now I would like the sort order for posts withing the blog to be configurable with a field in the blog settings. This works fine in the frontend, but how can I do the same in the panel? I tried playing around with the sortBy property, but it only accepts a string value, not something like a method defined on the model (blog.php).

So ideally, I would like the blog section to look like this:

info: "{{ page.contentDetails }}"
type: pages
sortBy: page.sortOrder
templates:
  - post

Where the sortOrder field is defined as follows:

sortOrder:
  default: published_desc
  icon: funnel
  label: Sort by
  options:
    manual: manual
    title_asc: Title asc
    title_desc: Title desc
    modified_asc: Modified asc
    modified_desc: Modified desc
    published_asc: Published asc
    published_desc: Published desc
  type: select
  width: 1/3

In this scenario, post has a field published as well.

Maybe with the Pagetable Plugin? I have used this sometimes and it’s amazing!!!

1 Like

Looks fantastic indeed! But sortBy is inherited from the pages type, so this leaves me with the same problem. I will install it and have a look if I can somehow tweak it to my needs.

Thanks!

With the plugin Pagetable you can click on the header of the columns you configure and the sort by it asc or desc on the 2nd click. The pages section doesn’t have a similar function. I guess you could extend it making your on plugin?

@Turqueso Yes, the sortable page headers are enough for now. Maybe I will write a plugin to allow dynamic values for sortBy.