1

I'm using {exp:stash:set_list} along with a few Matrix fields, but when I use {exp:stash:get_list} in my view template to retrieve the values nothing is returned. Here's barebones example of what I'm using.

Model template:

{stash:embed:layouts:template}

{exp:stash:set_list
  name="people_entry:{segment_2}"
  parse_tags="yes"
  parse_depth="2"
}

  {exp:channel:entries
    channel="people"
    disable="categories|category_fields|member_data|pagination"
    limit="1"
    status="open"
  }

        {stash:people_title}{title}{/stash:people_title}

        {exp:stash:set_list:nested
          name="name_{entry_id}"
          parse_tags="yes"
        }
          {matrix_field_1}
            {stash:people_name}
                {playa_field}
                    {name}
                {/playa_field}
            {/stash:people_name}
          {/matrix_field_1}
        {/exp:stash:set_list:nested}  

        {exp:stash:set_list:nested
          name="position_{entry_id}"
          parse_tags="yes"
        }
          {matrix_field_2}
            {stash:people_position}
                {playa_field}
                    {position}
                {/playa_field}
            {/stash:people_position}
          {/matrix_field_2}
        {/exp:stash:set_list:nested}

{/exp:stash:set_list}

View template:

{exp:stash:get_list
    name="people_entry:{segment_2}"
}

    {people_title}

    {exp:stash:get_list:nested
        name="name_{entry_id}"
    }
        {people_name}
    {/exp:stash:get_list:nested}

    {exp:stash:get_list:nested
        name="position_{entry_id}"
    }
        {people_position}
    {/exp:stash:get_list:nested}

{/exp:stash:get_list}

Any thoughts on what I'm doing wrong?

Using EE 2.7.3 with Stash 2.4.8 and Matrix 2.5.10.

1

The inner nested list needs to be assigned a context that identifies it as belonging to a specific row in the outer list - in this case {entry_id} would be a good choice since it is a unique value. Note that I have assumed your playa field is returning a single result - if not you would need another nested list to capture each playa entry and associate it with the parent matrix row_id.

  {exp:stash:set_list
    name="people_entry"
    context="{segment_2}"
    parse_tags="yes"
    parse_depth="2"
  }
    {exp:channel:entries
      channel="people"
      disable="categories|category_fields|member_data|pagination"
      limit="1"
      status="open"
    }
        {stash:people_title}{title}{/stash:people_title}

        {!-- unique reference to child list  --}
        {stash:entry_id}{entry_id}{/stash:entry_id}

        {!-- nested list --}
        {exp:stash:set_list:nested
          name="names"
          context="{entry_id}"
          parse_tags="yes"
          parse_depth="2"
        }
          {matrix_field_1}

            {stash:name}
              {playa_field limit="1"}
                  {name}
              {/playa_field}
            {/stash:name}

          {/matrix_field_1}
        {/exp:stash:set_list:nested}  

    {/exp:channel:entries}

  {/exp:stash:set_list}

When you get the list the entry id of the outer get_list row is passed to the nested get_list so that the list associated with that particular row is retrieved:

  {exp:stash:get_list name="people_entry" context="{segment_2}"}

      {people_title}

      {exp:stash:get_list:nested name="names" context="{entry_id}" prefix="nested"}

          {nested:name}

      {/exp:stash:get_list:nested}

  {/exp:stash:get_list}
| improve this answer | |
1

I think you need to capture the entryid as a stash var so you can call it instead of entry_I'd because entry_id doesn't exist when calling the get_list.

{stash:embed:layouts:template}

{exp:stash:set_list
name="people_entry:{segment_2}"
parse_tags="yes"
parse_depth="2"
}

{exp:channel:entries
channel="people"
disable="categories|category_fields|member_data|pagination"
limit="1"
status="open"
}

    {stash:people_title}{title}{/stash:people_title}
    //Capture entryID
    {stash:entryid}{entry_id}{/stash:entryid}
    {exp:stash:set_list:nested
      name="name_{entry_id}"
      parse_tags="yes"
    }
      {matrix_field_1}
        {stash:people_name}{name}{/stash:people_name}
      {/matrix_field_1}
    {/exp:stash:set_list:nested}  

    {exp:stash:set_list:nested
      name="position_{entry_id}"
      parse_tags="yes"
    }
      {matrix_field_2}
        {stash:people_position}{position}{/stash:people_position}
      {/matrix_field_2}
    {/exp:stash:set_list:nested}

{/exp:stash:set_list}



{exp:stash:get_list
name="people_entry:{segment_2}"
}

{people_title}

{exp:stash:get_list:nested
    name="name_{entryid}" //Unsure of syntax here, could try…
    name="name_{stash:entryid}"
}
    {people_name}
{/exp:stash:get_list:nested}

{exp:stash:get_list:nested
    name="position_{stash:entryid}"} //stashed entryid var
    {people_position}
{/exp:stash:get_list:nested}

{/exp:stash:get_list}
| improve this answer | |
  • I forgot to mention that the Matrix field contains Playa entries. Will update my example. – Roger Erik Tinch Jan 30 '14 at 18:08

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.