Sorting Custom Types in Sculpin
This blog post was published more than one year ago and might be outdated!
· One min read
Recently I played around with Sculpin. Pretty quickly I ran into an issue: I created a custom data type called events and wanted to sort the events by date. It seemed not possible as I could not figure out how to influence the sorting order in my twig template. By accident, I came across this issue on gihub in which Beau Simensen explains how to influence the sorting of the records. In a nutshell this is how it works: Create a file app/config/sculpin_services.yml:
services:
sculpin_content_types.types.events.collection.sorter:
class: Sculpin\Contrib\ProxySourceCollection\Sorter\MetaSorter
arguments:
- date
.events. identifies the custom type you want to change the sort order for. As argument, you list the field which should be sorted, date in my case. Let the generator run to see the difference.