0

Using EE 273 and stash 252.

As soon as I add a prefix parameter to a get_list, stash variables inside the list are not rendering.

Set_list part

{!-- Get last 3 news --}
{exp:stash:set_list name="st_latestnews" parse_tags="yes"}

    {exp:channel:entries
        channel="news"
        disable="categories|category_fields|member_data|pagination"
        orderby="date"
        sort="desc"
        limit="3"
        dynamic="no"
    }
        {stash:st_item_title}{title}{/stash:st_item_title}
        {stash:st_item_url}{url_title_path="news_press/news_detail"}{/stash:st_item_url}
        {stash:st_item_date}{entry_date format="%F %j, %Y"}{/stash:st_item_date}
        {stash:st_item_machinedate}{entry_date format="%Y-%m-%d"}{/stash:st_item_machinedate}
        {stash:st_item_img}{news_img}{/stash:st_item_img}
        {stash:st_item_img_caption}{news_img_caption}{/stash:st_item_img_caption}
        {stash:st_item_img_copyright}{news_img_copyright}{/stash:st_item_img_copyright}
        {stash:st_item_summary}{news_summary}{/stash:st_item_summary}
    {/exp:channel:entries}

{/exp:stash:set_list}

Get list without prefix: works (but no_results does not)

Everything is rendered fine but no_results does not work here. Tried adding parse_conditionals="yes" and parse_tags="yes" but no dice.

{!-- display news list --}
{exp:stash:get_list name="st_latestnews"}

    {if count == 1}<ul class="list-compact  grid"><li class="grid__unit  medium-unit-4of12">{/if}
        <article>
            <p class="imgholder"><a href="{st_item_url}">{exp:ce_img:pair src="{st_item_img}" width="600" height="337" crop="yes|center,center" allow_scale_larger="yes"}<img src="{made}" alt="{st_item_img_caption} - &copy; {st_item_img_copyright}" class="fluidimg" />{/exp:ce_img:pair}</a></p>
            <p class="item-meta"><time datetime="{st_item_mdate}">{st_item_date}</time></p>
            <h2 class="item-title  item-title--small"><a href="{st_item_url}">{st_item_title}</a></h2>
            <p>{exp:eehive_hacksaw words="30" append="&hellip;"}{st_item_summary}{/exp:eehive_hacksaw}</p>
        </article>
    {if count == total_results}</li></ul>{if:else}</li><li class="grid__unit  medium-unit-4of12">{/if}

    {!-- handling no result --}
    {if no_results}<p>No news found</p>{/if}

{/exp:stash:get_list}

Get list with prefix: variables do not render (but no_results works)

With previous versions of Stash, this used to work to get the no_results tag to behave properly. Here, as soon as I add a prefix parameter, nothing renders, although the list is correctly populated and retrieved in the template debugger.

{!-- display news list --}
{exp:stash:get_list name="st_latestnews" prefix="stashprefix"}

    {if count == 1}<ul class="list-compact  grid"><li class="grid__unit  medium-unit-4of12">{/if}
        <article>
            <p class="imgholder"><a href="{st_item_url}">{exp:ce_img:pair src="{st_item_img}" width="600" height="337" crop="yes|center,center" allow_scale_larger="yes"}<img src="{made}" alt="{st_item_img_caption} - &copy; {st_item_img_copyright}" class="fluidimg" />{/exp:ce_img:pair}</a></p>
            <p class="item-meta"><time datetime="{st_item_mdate}">{st_item_date}</time></p>
            <h2 class="item-title  item-title--small"><a href="{st_item_url}">{st_item_title}</a></h2>
            <p>{exp:eehive_hacksaw words="30" append="&hellip;"}{st_item_summary}{/exp:eehive_hacksaw}</p>
        </article>
    {if count == total_results}</li></ul>{if:else}</li><li class="grid__unit  medium-unit-4of12">{/if}

    {!-- handling no result --}
    {if stashprefix:no_results}<p>No news found</p>{/if}

{/exp:stash:get_list}

Is this a bug or am I missing something obvious here (as it could well be the case) ?

1

The ever helpful Mark Croxton promptly responded via twitter.

From the changelog:

Stash 2.4.8: When using the prefix="x", parameter with get_list, only prefixed variables will now be parsed by default, unless require_prefix="no"

So the correct code for your variables to be parsed without prefix and the no_result tag to be working is as follows:

{!-- display news list --}
{exp:stash:get_list name="st_latestnews" prefix="myprefix" require_prefix="no"}

    {if count == 1}<ul class="list-compact  grid"><li class="grid__unit  medium-unit-4of12">{/if}
        <article>
            <p class="imgholder"><a href="{st_item_url}">{exp:ce_img:pair src="{st_item_img}" width="600" height="337" crop="yes|center,center" allow_scale_larger="yes"}<img src="{made}" alt="{st_item_img_caption} - &copy; {st_item_img_copyright}" class="fluidimg" />{/exp:ce_img:pair}</a></p>
            <p class="item-meta"><time datetime="{st_item_mdate}">{st_item_date}</time></p>
            <h2 class="item-title  item-title--small"><a href="{st_item_url}">{st_item_title}</a></h2>
            <p>{exp:eehive_hacksaw words="30" append="&hellip;"}{st_item_summary}{/exp:eehive_hacksaw}</p>
        </article>
    {if count == total_results}</li></ul>{if:else}</li><li class="grid__unit  medium-unit-4of12">{/if}

    {!-- handling no result --}
    {if myprefix:no_results}<p>No news found</p>{/if}

{/exp:stash:get_list}

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.