1

I have nodes that have embedded Media (images) and also links to other content (nodes and media). Through hooks I populate custom fields to store those references, this is a multi-value entity reference. Also, since the entity reference is an int, the default filter is equals, between, less or greater, etc - 'not in' is not even possible via the UI.

What I would like to do is create a View that would find content where those references are no longer valid; ie. the referenced entity has been removed.

I attempted to use a few hook_views_XXX functions to alter the query or filter the results after execution. Altering the query makes the most sense, but am not sure how to add an IN clause for a custom field. Filtering the results 'post_execute' will be cumbersome since there is not a way good way to get all results before the pager is initialized.

Creating a custom views filter is going to be the next attempt, but would think/hope that there is a simpler way. Is there something I am overlooking? How can the 'query_alter' be done?

3
  • Why do you need to alter the query? Why won't a filter work?
    – Jaypan
    May 19, 2023 at 13:25
  • If a filter can be done that is great, but I can not figure out how to do a 'NOT IN' with a multi value entity reference field. May 19, 2023 at 18:06
  • You should add the 'multi value' part to the original post, as it's a fairly important bit of context.
    – Jaypan
    May 20, 2023 at 0:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.