Sorting Custom Types in Sculpin

Sorting Custom Types in Sculpin

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 influcence the sorting order in my twig template. By accident I came accross 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. identfies the custom type you want to change the sort order for. As argument you list the field which sould be sorted, date in my case. Let the generator run to see the difference.


Eintrag von Stephan Hochdörfer am 02.09.2015

Tags: PHP, Sculpin

Diese Webseite verwendet Cookies, um die Bedienfreundlichkeit zu erhöhen. Mit der Nutzung unserer Webseite wird das Einverständnis erklärt, dass wir Cookies verwenden. Weitere Informationen.