Grouping entries by chosen fieldtype instead of date

Hi all

I have a numerical ordered collection and I would like to do something similar to this → grouping entries by date, but with an other fieldtype for grouping than the date.

Use case: A list of all collection entries, different projects in different cities, grouped by their city names. The final rendering should look like this:

<h3>New York</h3>
    <li>Project 1</li>
    <li>Project 2</li>
    <li>Project 3</li>
    <li>Project 4</li>
    <li>Project 5</li>

Adapting the group_by_date example, the template could look something like this.

{{ collection:projects filter="city_name" as="entries" }}
    {{ city_groups }}
        <h3>{{ city_group }}</h3>
            {{ entries }}
                <li>{{ title }}</li>
            {{ /entries }}
    {{ /city_groups }}
{{ /collection:projects }}

I know I need to write a custom filter, but unfortunately I have no clue how to write this in PHP. Maybe someone did already something similar?

Thank you very much. Daniel

>>>>>>> Unanswered <<<<<<<
1 Reply
1 Follower