2

I'm new to Stash and I'm trying to get the data from a Matrix field. The field has two columns, image and video, and there can be more than one matrix row.

I've used the example from the Stash documentation but it's still not working for me. I am getting the non-matrix data fine but not the Matrix items. Can anyone spot what I'm missing?

Thanks.

{if segment_2_category_id}
            {exp:stash:set_list name="news_list" parse_tags="yes" parse_depth="2"}
                {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10" category="{segment_2_category_id}"}
                    {stash:item_title}{title}{/stash:item_title}
                    {stash:item_url}{url_title}{/stash:item_url}
                    {stash:item_date}{entry_date format="%F %d, %Y "}{/stash:item_date}
                    {stash:item_copy}{news_content}{/stash:item_copy}

                    {exp:stash:set_list:nested name="item_media" context="{entry_id}" parse_tags="yes"}
                        {news_videos_images}
                            {stash:item_image}{image}{/stash:item_image}
                            {stash:item_video}{video}{/stash:item_video}
                        {/news_videos_images}
                    {/exp:stash:set_list:nested} 

                {/exp:channel:entries}
            {/exp:stash:set_list}
        {if:else}
        {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10"}
            {title}
        {/exp:channel:entries}
        {/if}


    {exp:stash:get_list name="news_list"}
        <div class="row blog-post-item">

        {exp:stash:get_list:nested name="item_media" context="{item_entry_id}" prefix="nested"}
            <div class="{nested:switch='row|rowAlt'}">
                <p>{item_video}</p>
                <p>{item_image}</p>
            </div>

        {/exp:stash:get_list:nested}

            <div class="row">
                <div class="description col-xs-12">
                    <h2>
                        <span class="date">{item_date}</span>
                        {item_title}
                    </h2>
                    {item_copy}
                    <a class="blue" href="{item_url}" title="{item_title}">Read more</a>
                </div><!-- /description-->  
            </div><!--  /row-->

        </div><!-- /row blog-post-item-->
    {/exp:stash:get_list}
0

You're trying to use {item_entry_id} for the context parameter when outputting your item_media list, but it doesn't look like it was set? Try adding:

{stash:item_entry_id}{entry_id}{/stash:item_entry_id}

to news_list when you're setting it.

| improve this answer | |
  • Thank you, that did the trick. Looks like I'd removed the initial line from the example in the docs. – KoalaKid Feb 12 '14 at 21:27
  • 1
    Awesome. Would you mind marking this as the answer so I can receive the fuzzy bunny award I'm sure I get at 2000 points? – Romans-8---31-39 Feb 12 '14 at 23:20

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.