0

I have the following blocks of code that I can't seem to to work correctly. The list sets and populates perfectly, but the switchee statement doesn't work. I konw that it has do do with parse order but I can't figure out what is going on. The debug value of for the switchee tag is this:

{exp:switchee variable="M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr" parse="inward"}

It seems as though switchee is running before stash is parsing list_count, is there any way to fix this?

{exp:stash:set_list name="buy_now_options" parse_depth="4" parse_tags="yes" trim="yes"}
    {exp:channel:entries entry_id="{lv_site_buy_now}" status="open|closed" order_by="entry_id" sort="asc" limit="3"}
        {stash:title}{title}{/stash:title}
        {stash:item_entry_id}{entry_id}{/stash:item_entry_id}
        {stash:url_title}{url_title}{/stash:url_title}
        {stash:logo}{partner_logo:url}{/stash:logo}
        {stash:base_url}{partner_base_purchase_url}{/stash:base_url}
        {exp:stash:set_list:nested name="purchase_urls" context="{entry_id}" parse_tags="yes"}
            {partner_retail_urls}
                {stash:product}{partner_retail_urls:product:title}{/stash:product}
                {stash:url}{partner_retail_urls:url}{/stash:url}
            {/partner_retail_urls}
        {/exp:stash:set_list:nested}
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="buy_now_options" parse_tags="yes" parse_conditionals="yes"}
    {exp:switchee variable="{exp:stash:list_count name='purchase_urls' context='{item_entry_id}'}" parse="inward" }
        {case value="0"}
            true
            <li><a href="{base_url}" target="_blank"><img src="{logo}" alt="{title} Web Store" /></a></li>
        {/case}
        {case default="yes"}
            false
            <li><a href="{base_url}" data-reveal-id="{url_title}-modal"><img src="{logo}" alt="{title} Web Store" /></a></li>
        {/case}
    {/exp:switchee}
{/exp:stash:get_list}
  • Shot in the dark, but have you tried "nested" or another string after list_count? ...list_count:nested – Romans-8---31-39 Oct 9 '14 at 18:14
  • I just tried it, but it has the same result – JeremyC Oct 9 '14 at 19:44
1

It looks like you're simply testing to see if the nested entries are empty or not. Could you not use something like:

{exp:stash:get_list name="buy_now_options" parse_tags="yes" parse_conditionals="yes"}
  {exp:stash:get_list:nested name="purchase_urls"}
  {if no_results}Show default link{/if}
  // There must be entries so show them
  {exp:stash:get_list:nested}
{/exp:stash:get_list}
| improve this answer | |

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.