I have a setup where I have to parse information from a matrix field that is nested within a playa loop.

The template code would look like this:








Unfortunately the {matrix_field} would not parse. Any idea how to make the matrix field parse other than to place it outside the {playa} loop?



here is the longer version:

I would like to add a couple af products at the same time in a ct cart.

The products I add recide in a matrix that contains a playa field. The matrix is a recipe and the ingredients are the playa field that come from a product/ingredients channel. The quantity is defined with the matrix field {quantity}.

a basic example is this:

{exp:cartthrob:multi_add_to_cart_form return="/store/cart"}
                <ul>You will need:
                            {products}{!-- playa field --}
                                <input type="hidden" name="entry_id[{entry_id}]" value="{entry_id}" />
                                <input type="input" name="quantity[{entry_id}]" value="{quantity}" />
                                (price:{product_price} each)


<input type="submit" value="add to cart"/> 



The problem with the above setup is that the quantity is not rendering. I found a couple of ways to make this work but they were all looking clumsy. One was to wrap playa fields in the playa tag pairs leaving the quantity field outside the playa loop. That left me with a far to verbose template code.

  • Can you provide a little context with regard to what you're trying to do? A Matrix field inside a Playa field, inside a Matrix field sounds uniquely deep. There may well be another way to do it. – Ian Apr 16 '13 at 7:49
  • Hey Christian - have you tried the approach here? pixelandtonic.com/playa/docs/celltype It sounds fairly close to what you need. – Lisa Apr 16 '13 at 16:21
  • Hi Lisa Thanks for pointing this out. However the new docs [link]docs.pixelandtonic.com/playa[/link] don't show this feature anymore (or is it just me not being able to find it)? – Christian May 7 '13 at 14:24
  • I'm also running into this problem -- It seems like the embedded matrix fields don't loop. – Bryant Jul 15 '13 at 18:14

Have you tried using Stash for this?

Maybe something like this would work:

        {exp:stash:set name="whatever_matrix_fields"}{matrix_field}{/exp:stash:set}
            {exp:stash:get name="whatever_matrix_fields"}

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.