2

i'm quite new to ExpressionEngine so please forgive me if this is a stupid/badly formed question, but i could really use some help on this one.

So my problem is that within my template i have a matrix-loop, and within that loop i have another matrix loop, which depends on the value of the outer loop.

Here's how i would like it to work:

{outer_matrix_field var_prefix="outer"}
    {another_matrix_field var_prefix="inner"}
        {if inner:package_{outer:row_count} == "y"}
            .. do stuff in here ..
        {/if}
    {/another_matrix_field}
{/outer_matrix_field}

The inner:package_{outer:row_count} gets parsed to inner:package_1, but that in turn is not parsed into its value.

It seems to me like it is some problem with the order of how EE parses/executes the tags, and i've tried with parse="inward" everywhere and that seems to do nothing.

Now i know that this could probably be solved using something like Playa, but that is not an option as the client has specifically asked for this solution.

So, what i need to know is if this is even possible.

Thank you

1
  • I solved it myself, using embeds, and passing the {row_count} as a variable. That made it parse things in the right order. So essentially what i did in the first place, only i broke out the inner loop to an embed. I also discovered the greatness of the matrix "search" option, but that's a whole other story. – andersandersson666 Oct 15 '13 at 13:32
2

Like you mentioned in your comment, embeds should do the trick, but be aware embeds are very costly to performance. If you have a big loop, and subsequently many embeds, you could see a rather significant performance decrease.

Instead of your normal embeds, you can also try using stash embeds. https://github.com/croxton/Stash/wiki/%7Bstash%3Aembed%7D

Also, take a look into ce caching to see if you can avoid having to run the potentially costly loop each page load. http://devot-ee.com/add-ons/ce-cache

3
  • Thank you for your thoughts. I will definitely look into stash embeds and ce caching. I thought maybe the built in ExpressionEngine-cache could also do the trick, as this content is not likely to change once an entry has been finalized. – andersandersson666 Oct 18 '13 at 12:31
  • Also, i would upvote your answer if i had the reputation to do so. – andersandersson666 Oct 18 '13 at 12:32
  • Yeah normal EE caching could do the trick too – Bryant Oct 18 '13 at 16:57

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.