0

I have a channel with a matrix field named expedition_days, and inside of that matrix, there is a playa column named resources. I am trying to create a stash list for each row of the matrix. It seems like you can't use the playa module tags inside of append_list, unless I'm missing something.

{exp:channel:entries
    channel="expedition"
    dynamic="no"
    limit="1"
}
    {expedition_days}
        {exp:stash:append_list
            name="expedition_days"
            parse_tags="yes"
        }
            {stash:item_day}{row_count}{/stash:item_day}
            {stash:item_location}{location}{/stash:item_location}

            {exp:playa:children
                col="resources"
            }
                {exp:stash:append_list:nested name="resources_{row_count}"}
                    {stash:item_title}{title}{/stash:item_title}
                {/exp:stash:append_list:nested}
            {/exp:playa:children}
        {/exp:stash:append_list}
    {/expedition_days}
{/exp:channel:entries}
2

Whenever I encounter these parse order issues with Stash, I find it helps to promote your Stash tags higher up the nesting hierarchy. Remember that the set and set_list methods automatically detect tags that loop, so often, you won't need to use the append methods. Try this for example:

{exp:channel:entries
    channel="expedition"
    dynamic="no"
    limit="1"
}

    {exp:stash:set_list name="expedition_days" parse_tags="yes"}
        {expedition_days}
            {stash:item_day}{row_count}{/stash:item_day}
            {stash:item_location}{location}{/stash:item_location}

            {exp:stash:set_list:2 parse_tags="yes" name="resources_{row_count}"}
                {exp:playa:children col="resources"}
                    {stash:item_title}{title}{/stash:item_title}
                {/exp:playa:children}
            {/exp:stash:set_list:2}

        {/expedition_days}
    {/exp:stash:set_list}

{/exp:channel:entries}

{!-- ==============================
TEST OUTPUT 
=================================== --}

{exp:stash:parse process="end"}
    <ul>
    {exp:stash:get_list name="expedition_days"}
        <li>
            <h3>day: {item_day} - location: {item_location}</h3>
            <ul>
              {exp:stash:get_list:2 name="resources_{item_day}"}
                 <li>{item_title}</li>
              {/exp:stash:get_list:2}
            </ul>
        </li>
    {/exp:stash:get_list}
    </ul>
{/exp:stash:parse}

Also, are you sure you want to use the playa:children tag? I don't know what your exact use-case is here, but you may find that using the simple primary tag pair ({resources}...{/resources}) gives you what you're looking for (assuming you're trying to output each row's related items, as opposed to the entire set of relationships in the column, which is what the playa:children tag will do).

| improve this answer | |
  • Just a note to point out that the Playa field replaces those {related}...{/related} tag pairs with {exp:playa:children row_id="n" col="resources"}...{/exp:playa:children} in any case. Trevor is just missing the row_id ="{row_id}" parameter, I think. – Mark Croxton Sep 30 '13 at 10:15
2

I actually realized that the nested list is completely unnecessary. Since I am building the list off of the matrix row, I can simplify it to be this:

{exp:channel:entries
    channel="expedition"
    dynamic="no"
    limit="1"
}
    {expedition_days}
        {exp:stash:append_list name="expedition_days"}
            {stash:item_day}{row_count}{/stash:item_day}
            {stash:item_location}{location}{/stash:item_location}
        {/exp:stash:append_list}

        {resources}
            {exp:stash:append_list name="resources_{row_count}"}
                {stash:item_title}{title}{/stash:item_title}
            {/exp:stash:append_list}
        {/resources}
    {/expedition_days}
{/exp:channel:entries}
| improve this answer | |

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.