Running into strange issue getting content into a Stash list from two grid field. A stripped down version of my code is below.

The two grid fields are {meeting_people} and {meeting_faculty}. In the entry I'm using to test this both grid fields have four rows. With the code below, all four rows of the field called first are stashed but only one row of the second field gets stashed.

Note: This is true even if the field order is switched in my code. That is, if I move {meeting_faculty} above {meeting_people}, all four rows of {meeting_faculty} are stashed while only one row of {meeting_people} gets stashed.

This is on an ExpressionEngine 2.9.2 build running Stash 2.6.2.

{exp:stash:set_list name="alt_faculty_{url_title}" scope="site" site="default_site" save="yes" parse_tags="yes" parse_depth="10"}
  {exp:channel:entries site="default_site" channel="meetings" url_title="{segment_2}" limit="1" dynamic="no"}

    <!-- first grid field - returns all  -->
      {meeting_people:name} <!-- start relationship field -->
        {stash:people_name}<em>people_name: </em>{meeting_people:name:title}{/stash:people_name}
      {/meeting_people:name}<!-- end relationship field -->

    <!-- second_grid field - returns only one -->
      {stash:faculty_name}<em>faculty_name: </em>{meeting_faculty:name}{/stash:faculty_name}


Let me show you how the parser will parse that code before Stash tries to capture it as a list. I'll assume your relationship field only allows you to select a single person:

{!-- first grid field --}
{stash:people_bio_override}Person 1 biography {/stash:people_bio_override}
{stash:people_director}Person 1 director{/stash:people_director}
{stash:people_name}<em>people_name: </em>Person 1 name{/stash:people_name}
{stash:people_credentials}Person 1 credentials{/stash:people_credentials}

{!-- first grid field --}
{stash:people_bio_override}Person 2 biography {/stash:people_bio_override}
{stash:people_director}Person 2 director{/stash:people_director}
{stash:people_name}<em>people_name: </em>Person 2 name{/stash:people_name}
{stash:people_credentials}Person 2 credentials{/stash:people_credentials}

{!-- first grid field --}
{stash:people_bio_override}Person 3 biography {/stash:people_bio_override}
{stash:people_director}Person 3 director{/stash:people_director}
{stash:people_name}<em>people_name: </em>Person 3 name{/stash:people_name}
{stash:people_credentials}Person 3 credentials{/stash:people_credentials}

{!-- second grid field --}
{stash:faculty_name}Faculty 1 name{/stash:faculty_name}
{stash:faculty_bio}Faculty 1 bio{/stash:faculty_bio}

{!-- second grid field --}
{stash:faculty_name}Faculty 2 name{/stash:faculty_name}
{stash:faculty_bio}Faculty 2 bio{/stash:faculty_bio}

A Stash list is simply a table of data. We can easily represent the first 3 repeating rows like this:

| people_bio_override     | people_director         | people_name             | people_credentials      |
| Person 1 biography      | Person 1 director       | Person 1 name           | Person 1 credentials    |
| Person 2 biography      | Person 2 director       | Person 2 name           | Person 2 credentials    |
| Person 3 biography      | Person 3 director       | Person 3 name           | Person 3 credentials    |

But the last 2 rows don't share the same column headings (keys) so needs to be represented as a separate table:

| faculty_name                          | faculty_bio                           |
| Faculty 1 name                        | Faculty 1 bio                         |
| Faculty 2 name                        | Faculty 2 bio                         |

The solution to your problem is therefore to create two Stash lists, one for the first grid field and another for the second grid field.

  • Thanks, Mark. I set this part of the project aside for a couple weeks but will be diving back into this later on in the week. Appreciate the diagrams. – Brooks Seymore Nov 8 '16 at 9:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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