3

Need to display if a Asset field within a Matrix field has a file or not. While this works, the overhead is really high. Is there a way to write this with less overhead? Based on the EE template debug, here's the simplified snippet that causes the most lag:

{exp:channel:entries}
       {exp:playa:parents}
          {if '{matrixfield search:assetfield="not IS_EMPTY"}{row_id}{/matrixfield}'!=""}
             I'm not blank!
          {/if}
       {/exp:playa:parents}
{/exp:channel:entries}

Using the search+row_id is most efficient way I've tested to write it, but it's still some 2k queries/8sec vs the 100/.xsec the site normally has. With the Asset in Matrix, in Playa, in Entries I would expect some additional processing time. Open to any ideas to try!

5
  • Could you not just check to see if the matrix cell is empty by using the matrix column name rather than actually checking the Asset field within the Matrix field?
    – Ian Young
    Apr 15, 2013 at 18:07
  • The column name calls the Assets plugin. {matrixfield}{asset_column_name}{/matrixfield} had even more overhead. Unless there's a way to ask for that column without using the cell name itself. Is that what you were suggesting or did I miss something?
    – Blair
    Apr 15, 2013 at 23:53
  • Blair, I think I'm confused as well. Have you tried {matrixfield}{if asset_column_name != ""}{row_id}{/if}{/matrixfield}?
    – Lisa
    Apr 16, 2013 at 22:04
  • I didn't know that was a tag. Where's the docs for it and I'll give it a shot?
    – Blair
    Apr 17, 2013 at 1:22
  • Ok, sorry, brain fail. The asset_column_name (what I called assetfield, which is really called audio_file) used in that way gives about another 300 queries. I did try that.
    – Blair
    Apr 18, 2013 at 0:16

1 Answer 1

1

I have the same problem - did you ever discover a good way to get around the n+1 problem?

Your Answer

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

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