I’ve got a metaobject for a locations. And I’m creating a list page that shows all of them. Think: these are our physical stores, and here’s info about each (photo, address, etc)
I’ve got a for loop that works, but when I try to use a sort filter, it blows up and returns nothing.
Any variation of sort, sort_natural, with or without more filtering (e.g. | sort: "name" ) doesn’t seem to work.
What I’m trying to actually achieve: I’m trying to do a smarter sort. I’ve got a name field, and a sort_name field, plus a bunch of others. And I’m trying to make the list sort by the sort_name, so that I can have “The First Place” under “F” not “T”
How is this list sorted? It’s not creation date, nor is it the selected display field in the metaobject. Turn out it’s actually sorting by the object’s handle.
So if I’ve got five stores:
Name
Handle
The First Store
the-first-store
The Second Store
the-second-store
A Third Store Name
a-third-store-name
Main Store
main-store
Aux Store
aux-store
They’ll sort, automatically, like:
A Third Store Name
Aux Store
Main Store
The First Store
The Second Store
Change the handles on those, get rid of the articles, so now they’re like this:
Name
Handle
The First Store
first-store
The Second Store
second-store
A Third Store Name
third-store-name
Main Store
main-store
Aux Store
aux-store
And now they sort differently:
Aux Store
The First Store
Main Store
The Second Store
A Third Store Name
And this is what I was trying to accomplish.
There’s stuff that needs adding to the documentation, i think. Because it (and the ai chat bot) says that we can apply array filters to metaobjects. But it doesn’t seem like we can in this case. But you can manipulate the object handle to revise your sorting.