1

I'm trying to display two columns of EE entries, each entry has a grid field with a text field and an Assets field. I thought I was close on this, but clearly I'm missing the boat because the grid portion isn't spitting anything out :(

{embed="_layout/main"}
{preload_replace:the_channel="publications"}
{exp:stash:set_value name="title" value="Publications"}

{exp:stash:set name="content"}
<h1>Publications</h1>

<p class="lead-in">{lv_publications_leadin}</p>

{exp:stash:set_list name="pub" parse_tags="yes" save="yes" scope="site"}
{exp:channel:entries
    channel="{the_channel}"
    disable="categories|category_fields|member_data|pagination"
    limit="20"
    sort="desc"
    status="Open"
    show_future_entries="yes"
}
        {stash:publication_title}{title}{/stash:publication_title}

        {exp:stash:set_list:nested name="entry_files" context="{entry_id}" parse_tags="yes"}    
            {publication}
                {stash:publication_year}{publication:year}{/stash:publication_year}
                {stash:publication_file}{publication:file}{/stash:publication_file}
            {/publication}
        {/exp:stash:set_list:nested}

{/exp:channel:entries}
{/exp:stash:set_list}

<div class="w-row">
    <div class="w-col w-col-6">
        {exp:stash:get_list name="pub" sort="desc" limit="1/2"}
        <div class="_97 card">
            <h4>{publication_title}</h4>
            <ul class="card-list">
                {exp:stash:get_list:nested name="entry_files" context="{item_entry_id}" prefix="nested"}
                <a href="{publication_file}"><li>{publication_year} {publication_title}</li></a>
                {/exp:stash:get_list:nested}

            </ul>
        </div>
        {/exp:stash:get_list}
    </div>
    <div class="w-col w-col-6">
        {exp:stash:get_list name="pub" sort="desc" offset="1/2" limit="1/2"}
        <div class="card">
             <h4>{publication_title}</h4>
            <ul class="card-list">

                {exp:stash:get_list:nested name="entry_files" context="{item_entry_id}" prefix="nested"}
                <a href="{publication_file}"><li>{publication_year} {publication_title}</li></a>
                {/exp:stash:get_list:nested}

            </ul>
        </div>
        {/exp:stash:get_list}
    </div>

</div>
{/exp:stash:set}

2 Answers 2

1

Suspect it is because you are using different context settings between setting the list and getting it back again.

You set the list using {entry_id} as the context. You retrieve the list using {item_entry_id} as the context.

But you don't seem to be setting / saving the value {item_entry_id}.

If you are basing this code on the examples on the lists page of the stash wiki, you'll see that in those the examples explicitly store the {item_entry_id} value based on {entry_id} as follows in the example given on that page:

{exp:stash:set_list name="my_list" parse_tags="yes" parse_depth="2"}
    {exp:channel:entries channel="clients" limit="5"}

        {stash:item_title}{title}{/stash:item_title}
        {stash:item_entry_id}{entry_id}{/stash:item_entry_id}

        {exp:stash:set_list:nested name="related_entries" context="{entry_id}" parse_tags="yes"}
            {!-- this could be a Matrix or Playa tag pair --}
            {contact_docs}
                {stash:related_title}{mx_title}{/stash:related_title}
            {/contact_docs}
        {/exp:stash:set_list:nested}    

    {/exp:channel:entries}  
{/exp:stash:set_list}

HTH

2
  • Thank you for pointing out that one line that ended up guiding me to the solution! I ended up changing this from a grid to a matrix field, along with adding the prefix "nested" to my matrix fields in the stash get_list portion. Here is my working code in case it helps anyone else.
    – soire
    Jun 28, 2017 at 15:02
  • Great - glad you got it working Jun 28, 2017 at 15:19
0
    {embed="_layout/main"}
{preload_replace:the_channel="publications"}
{exp:stash:set_value name="title" value="Publications"}

{exp:stash:set name="content"}
<h1>Publications</h1>

<p class="lead-in">{lv_publications_leadin}</p>

{exp:stash:set_list name="pub" parse_tags="yes" parse_depth="2"}
{exp:channel:entries
    channel="{the_channel}"
    disable="categories|category_fields|member_data|pagination"
    limit="20"
    sort="desc"
    status="Open"
    show_future_entries="yes"
}
        {stash:publication_title}{title}{/stash:publication_title}
        {stash:item_entry_id}{entry_id}{/stash:item_entry_id}
        {exp:stash:set_list:nested name="entry_files" context="{entry_id}" parse_tags="yes"}    
            {publication}
                {stash:publication_year}{year}{/stash:publication_year}
                {stash:publication_file}{file}{/stash:publication_file}
            {/publication}
        {/exp:stash:set_list:nested}

{/exp:channel:entries}
{/exp:stash:set_list}

<div class="w-row">
    <div class="w-col w-col-6">
        {exp:stash:get_list name="pub" sort="desc" limit="1/2"}
        <div class="_97 card">
            <h4>{publication_title}</h4>
            <ul class="card-list">
                {exp:stash:get_list:nested name="entry_files" context="{item_entry_id}" prefix="nested"}
                <a href="{nested:publication_file}"><li>{nested:publication_year} {publication_title}</li></a>
                {/exp:stash:get_list:nested}

            </ul>
        </div>
        {/exp:stash:get_list}
    </div>
    <div class="w-col w-col-6">
        {exp:stash:get_list name="pub" sort="desc" offset="1/2" limit="1/2"}
        <div class="card">
             <h4>{publication_title}</h4>
            <ul class="card-list">

                {exp:stash:get_list:nested name="entry_files" context="{item_entry_id}" prefix="nested"}
                <a href="{nested:publication_file}"><li>{nested:publication_year} {publication_title}</li></a>
                {/exp:stash:get_list:nested}

            </ul>
        </div>
        {/exp:stash:get_list}
    </div>

</div>
{/exp:stash:set}

My working code mentioned above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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