[SOLVED] Filter by property

Hey there,

is it possible to filter elements by a specific property which is a reference (type «references»)?

I have the following problem: I’ve created a new node element that should display the latest 5 news (articles). But I don’t know how this works. I can’t find anything in the forum or the documentation. I’ve tried «filter» and «filterByReference» but that’s not working. I got «filterByReference» via Google but I can’t even find it in the Neos / Flow documentation.

prototype(Xyz.Website:News) < prototype(Xyz.Website:Content) {
    templatePath = 'resource://Xyz.Website/Private/Templates/NodeTypes/News.html'

    headline = ${q(node).property('headline')}
    subheadline = ${q(node).property('subheadline')}
    tags = ${q(node).property('tags')}
    count = ${q(node).property('count')}
    newest = ${q(site).find('[instanceof Xyz.Website:Article]').filter('tags', this.tags).sort('date', 'DESC').slice(0, this.count).get()}

«tags» is also a property of an «Xyz.Website:Article» and a reference to «Xyz.Website:Tag». An article can have one or more tags.


I wrote a custom operation for this in my blog package, maybe that helps: https://github.com/Sebobo/Shel.Blog/blob/master/Classes/Fusion/FlowQueryOperations/FilterByReferenceOperation.php

1 Like

Hi Sebastian,

yes that does the trick. I’ve had to adjust it for my needs, because $categories could be more than one. :slight_smile: Thank you!


If your version can do more, maybe you can link it as a Gist :slight_smile:

Yes sure :slight_smile:

1 Like