0

I am using this solution to get the latest article with a video. This works great, until I delete the Matrix block in my latest entry with video, then it still finds that entry, but without any data. I think Craft does not actually delete the Matrix block from the database?

I did not want to retrieve all items and then filter them in Twig, that's why I used orderBy and one(). How can I skip the Matrix blocks that are empty/deleted??

{% set videoNews = craft.entries .section('news') .leftJoin('{{%matrixblocks}} as matrixblocks', 'matrixblocks.ownerId = entries.id') .andWhere({'matrixblocks.typeId': 5 }) .orderBy('postDate desc') .one() %}

PS I am unable to comment in that thread, so I posted a new question, hope this is the way to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.