4

So in order to do this you have to reformat your code and your strategy a bit. You cant provide a Craft query as a link, all that does is grab an array from the database and it won't inherently print something out. <li><a href="{% set usersByFirstName = craft.users.search('sortAS', '{{ firstName}}') %}">A-Z</a></li> The best way to ...


4

One solution is to retrieve the entry ids for the season entries and all entries separately; subtract the 'season entry ids' from 'all entry ids' (using craft's without twig filter); then merge the two arrays back together (using twig's merge filter) in the proper order. You can then use this new id array to generate an elementCriteriaModel which can be used ...


4

I was able to accomplish this by just adding both variables to my SuperSort tag. In essence, what I did was this: {% set fruits = fruits | supersort('natsortas', '{count} {title}') %} It seems to be working in my situation, but if there's a better way to do it, I'm open to suggestions.


4

This is in no means an elegant solution, and can almost certainly be improved. But it did its job just fine. {% set veterinarians = craft.entries({ section: 'veterinarians', order: 'premiumVet desc, postDate desc', }) %} {# more filter/search params #} {% set entriesPerPage = 20 %} {% set page = craft.request.getParam('page') %} {% set page = page ...


3

Thanks for asking about this, Cole! There was a bug that was causing rsortAs to return erroneous results. The issue is fixed in the 1.0 release. Grab yourself a fresh copy and you should be squared away.


3

It won't work with getPrev and getNext, as they only work with ElementCriteriaModels and not with an array of Entry models. But that is what you get returned from the plugin. Supersort converts your craft.entries ElementCriteriaModel into an array of Entry models. This is necessary so that it can do the sorting. The only workaround I know of would be to ...


3

Try using the replace filter inside SuperSort's micro-template: {% set foo = craft.entries.section('foo')... %} {% set sortAsList = { 'ShopType1': "A", 'ShopType2': "B", 'ShopType3': "C" } %} {% set sortedFoo = foo | supersort('sortAs', '{ shopType | replace(sortAsList) }') %} The first parameter you pass to SuperSort specifies the sort ...


2

On natsort... When you're sorting a list of entries, the items being sorted are EntryModel objects. The natsort filter won't be very helpful in that case, because natsort is expecting string inputs. Instead you can use the natsortAs filter as described in the Scraper docs: {% entries | supersort('natsortAs', '{someStringField}') %} This way, SuperSort ...


2

Try to group the entries sorted by size using the group filter: {% set entriesSorted = entries|supersort('sortAs', '{ size }', SORT_NUMERIC) %} {% set entriesByBrand = entriesSorted|group('brand.first.title') %} {% set entriesByBrand = entriesByBrand|supersort('ksort') %} {% for brand, entriesInBrand in entriesByBrand %} {% for entry in entriesInBrand %...


2

I did something like this as a workaround: Loop over entries, fetching all data you need and adding it to an array. Sorting that array with SuperSort and than displaying all info by looping over the array. {% set tourDates = [] %} {% set artists = craft.entries.section('artists') %} {% for artist in artists %} {% if artist.tourDates %} {% for ...


2

I think you need to add 'object' to your syntax if you're using {{ }}: {{ object.tourDates.tourDate }} Else it's { tourDates.tourDate } I believe. See the plugins docs under Advanced sorting.


2

I recon Supersort is they way to go, as its got some really handy functions to make this sort of thing a breeze. Try with the following: {% set entries = craft.entries.section('presenters').order('RAND()').limit(10) %} {% set sortedEntries = entries | supersort('sortAs', '{lastName}') %} {% for item in sortedEntries %} {{ item.title }} {% endfor %}


2

Not really an answer that fixes the question per sé if anyone else has the same issue, but none the less the answer that worked for me was simple: Split up your sorting where possible and simplify things! I wanted my main array to be sorted by condition A, grouped by condition B and than sort the sub arrays alphabeticaly. All done to the same array in a ...


1

I used the preparse plugin to save a date value from a SuperTable field into a static field as 'yyyymmdd'. I could then sort my entries based on that static field.


1

Further to Jalen's answer, if you want to preserve your array keys, you can use this: {% set sortedArrayKeys = mySortedArray | keys %} and then access any item with mySortedArray[sortedArrayKeys[index]]


1

If you run mySortedArray through the | values filter, it will reset the keys: {% set mySortedArray = myArray | supersort | values %} mySortedArray = array(6) { [0]=int(1) [1]=int(2) [2]=int(3) [3]=int(5) [4]=int(7) [5]=int(9) }


1

Figured it out, needed to format the postDate object accordingly: {% set products = products | supersort('rsortAs', '{ postDate | date("U") }') %}


1

Managed to do this by putting it all into an array: {% set productID = [] %} {% set orders = craft.orders().limit(null).all() %} {% for order in orders %} {% for item in order.lineItems %} {% set productID = productID |merge([ { 'productId' : item.purchasable.product.customProductId, 'groupName' : order.groupName ...


1

So you're not getting your matrix field's value properly. You're going to want to access it the same way you'd output the data: {{ event.dates.type('date').first().startDate.getTimestamp() }} So what we're doing here is getting the dates matrix field, selecting the blocks that have a type of date, getting the first of those blocks (should be our only block ...


1

It's a bit hard to help as you didn't provide any code. But I suggest to apply the supersort filter before grouping by the department property. {% set usersSorted = users|supersort('sortAs', '{{ object.lastname }}') %} {% set usersGrouped = usersSorted|group('department') %}


1

I just gave it a play and found a simple solution to get them ordered by count in descending order and them by title in ascending order: {% set fruits = fruits|supersort('natsortas', '{{ (9999-object.count) ~ object.title }}') %}


Only top voted, non community-wiki answers of a minimum length are eligible