Skip to content
Discussion options

You must be logged in to vote

You might also be able to use the new computed values feature. https://statamic.dev/computed-values

Make a computed value that pulls the number out of the title and use that field for sorting.

// AppServiceProvider.php boot method

Collection::computed('numbered', 'order', function ($entry) {
    return (int) (string) str($entry->title)->afterLast(' ');
});

Tell the collection to sort by that field.

# content/collections/collectionname.yaml

sort_by: order

Optionally create a computed field in your blueprint that you could use to display the column in the listing:

  -
    handle: order
    field:
      type: integer
      visibility: computed
      listable: visible

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@beatwiz
Comment options

Answer selected by beatwiz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants