0

Yo,

I can't seem to figure this one out. I have a nested list of related Playa entires. Depending on if the list has a value, I want to show some code above the nested list.

<div class="well">
    <h4>How To Guides</h4>
    <ul>
    {exp:stash:get_list:nested name="related_guides-{e_id}"}
        <li><a href="{link}">{title}</a></li>
    {/exp:stash:get_list:nested}
    </ul>
</div>

I only want to show the 'well' div IF there is something to show.

Here is the nested list:

{exp:stash:set_list:nested name="related_guides-{entry_id}" parse_tags="yes" scope="site" save="no" replace="no" refresh="1440"}
        {filt_related_guides site="ht"}
            {stash:link}{title_permalink="guides/index"}{/stash:link}
            {stash:title}{title}{/stash:title}
        {/filt_related_guides}
        {gen_related_guides site="ht"}
            {stash:link}{title_permalink="guides/index"}{/stash:link}
            {stash:title}{title}{/stash:title}
        {/gen_related_guides}
        {pump_related_guides site="ht"}
            {stash:link}{title_permalink="guides/index"}{/stash:link}
            {stash:title}{title}{/stash:title}
        {/pump_related_guides}
        {tub_related_guides site="ht"}
            {stash:link}{title_permalink="guides/index"}{/stash:link}
            {stash:title}{title}{/stash:title}
        {/tub_related_guides}

        {if no_results}{exp:stash:set_value name="no_related" value="0"}{/if}
    {/exp:stash:set_list:nested}

Anyone got a solution to this? Or point out what I'm doing wrong?

Cheers

1 Answer 1

1

Well, you created your own solution.

To prevent conflicts, change the value of no_related to something diferent of "0".

{if no_results}{exp:stash:set_value name="no_related" value="yes"}{/if}

Then, use a conditional, but put this code on an embed, to make it be parsed after your nested list:

{if "{exp:stash:get name='no_related'}" != "yes"}
    <div class="well">
        <h4>How To Guides</h4>
        <ul>
        {exp:stash:get_list:nested name="related_guides-{embed:e_id}"}
            <li><a href="{link}">{title}</a></li>
        {/exp:stash:get_list:nested}
        </ul>
    </div>
{/if}

Or, you can just use the not_empty single variable and to no create the no_related:

{if {exp:stash:not_empty name="related_guides-{embed:e_id}"}}
    <div class="well">
        <h4>How To Guides</h4>
        <ul>
        {exp:stash:get_list:nested name="related_guides-{embed:e_id}"}
            <li><a href="{link}">{title}</a></li>
        {/exp:stash:get_list:nested}
        </ul>
    </div>
{/if}
1
  • Thanks Robson. I thought I was almost there. I will give them a go. I'd not seen the not_empty tag before. Very useful. Thanks again.
    – T2theC
    Jul 19, 2013 at 10:35

Your Answer

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

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