How to filter in FlowQuery for nodes with certain properties set or unset?

(Dmitri Pisarev) #1

Answer by Aske:
.filter('[propertyName][propertyName != ""]') – finds all with that attribute where it’s not empty.
.filter('[propertyName][propertyName = ""]') – finds all with that attribute being empty.
.filter('[propertyName], [propertyName = ""]') – finds all with that attribute (regardless of value) and those with an empty value exactly like jQuery however it’s true that it’s not possible to find those without that attribute in any way, for that we should finish the not operation (NEOS-1146)

(Aske Ertmann) #2

Related to this, for image properties you need to check the type:
[image instanceof TYPO3\Media\Domain\Model\ImageInterface]

No need to check if the property is set though.

(George Dimitriadis) #3

Useful information.

I was looking for an example of such usage here without success.

(Dmitri Pisarev) #4

Good point. Maybe you could update the docs with a bit more examples, and we’d review it?

(George Dimitriadis) #5

I would love to, but I’m working on a project that went badly off-schedule.

Maybe on my next project I’ll get the chance to contribute more.

(George Dimitriadis) #6

Any idea if I can make the filter operation case insensitive ?

.filter('[title *= "first"]') Doesn’t work if the node’s title contains ‘First’

The jQuery equivalent to make this work would be .filter('[title *= "first" i]') , but unfortunately it’s not implemented.

(Aske Ertmann) #7

Hey George,

Unfortunately there’s no way to make it case insensitive, however you can add more filters acting like or like this:


(Dmitri Pisarev) #8

Or write a custom FQ operation.

(George Dimitriadis) #9

I see, alright, thanks !

Exactly my thoughts, @dimaip, I just wanted to make sure there isn’t a better way.