0

I am using a plugin to fetch Entry elements based on various criteria (eg to produce an array based on \craft\elements\Entry::find()).

The section I am querying features a number of related categories that I want to filter the entries by. So far so good …

However where am hitting issues is wanting to sort the results based on the related categories.

I can see the SuperSort plugin has a helper method that should enable this but am struggling to get it to work.

For example, if I try

$results = SuperSort::$plugin->sorter->superSort($results, 'asort', '{{ object.country.first.title }}', 'SORT_REGULAR');

where $results is the array of results from my Entries query and country is the field for selecting the country category I get the following error:

level too deep - recursive dependency

Can the SuperSort method be used in a plugin in conjunction with related Elements or is this only for use via twig?

Your Answer

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

Browse other questions tagged or ask your own question.