2

.find has been deprecated and we are told to use .all() instead. This seems to work for cases that don't have Eager Loading going on, but fails when eager loading is tried.

My working Craft 2 code might be:

{% set mixedContent = entry.mixedContent.find({
    with: [
        'singleImage:image',
        'imageGallery:images',
        'download:file',
        'relatedItems:relatedItems'
    ]
}) %}

Simply transposing ".find" with ".all" results in the following error:

Error: Call to a member function getQueryBuilder() on array

Switching the syntax I tried:

{% set mixedContent = entry.mixedContent({
    with: [
        'singleImage:image',
        'imageGallery:images',
        'download:file',
        'relatedItems:relatedItems'
    ]
}).all() %}

But got this error:

Calling unknown method: craft\elements\Entry::mixedContent()

What am I doing wrong?

3

Assuming mixedContent is a Matrix or relational field, the correct syntax would be:

{% set mixedContent = entry.mixedContent.with([
    'singleImage:image',
    'imageGallery:images',
    'download:file',
    'relatedItems:relatedItems'
]).all() %}
| improve this answer | |
  • So entry.mixedContent(params) is not supported any longer, and what about craft.entries(params)? – carlcs Aug 10 '17 at 8:51
  • 1
    @carlcs mixedContent(params) wouldn’t have worked in v2 either; it’s just that all(params) doesn’t work like find(params) had. Yes, craft.entries(params) still works. – Brandon Kelly Aug 10 '17 at 15:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.