3

I have an events section with a custom field of eventDate and it would be very helpful to editors to have them listed in event date order. In Craft 2 I used the plugin CP Sortable Custom Columns by Mikkel Rummelhoff but he hasn't ported it to Craft 3 and may not, he says.

I would have thought this option would be useful to many people, so has anyone got any suggestions as to how to achieve it, I'm not a plugin developer myself.

1
  • I just went through this same issue and it's not currently possible in Craft 3. Ideally this would be a native abilitiy, but if not a plugin would be fine. – CreateSean Aug 6 '18 at 12:49
3

Craft 3.2 beta adds support sortable custom fields.

2

A few solutions:

  1. Hire someone to create a plugin for you
  2. Learn PHP in order to include the ability to sort those fields
  3. Create a feature request and hope Pixel and Tonic will include it

For those who want to sort entries by custom fields can read the docs in order to get to know how it is possible

Event::on(Entry::class, Element::EVENT_REGISTER_SORT_OPTIONS, function(RegisterElementSortOptionsEvent $event) {
    $event->sortOptions[] = [
        'orderBy' => 'content.field_eventDate', //<-- content. + handle of the field prefixed with field_ to match the database column
        'label' => 'My Awesome custom search',// <-- name of the label in the CP
        'attribute' => 'field:10' //<--- id of your field
    ];
});
1
  • Thanks Robin. 1. I'd rather not have a custom plugin created for me as maintaining it going forward is likely to be an issue. 2. I'm struggling to keep up with the amount of new code I need to learn for Craft 3 already, as well as the constant changes of development envirionment. 3. I've added a comment to the existing feature request. – Paul Frost Aug 7 '18 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.