1

Hi I am using playa on a real estate site.

I have properties listed with the realtor that is selling the property and I can get that working fine with playa. My issue is when I have a property that has two realtors selling it. I can listing both of them fine, but I want to have them displayed in an accordion if there are more than one realtor.

This is the code I have thus far :

 {exp:playa:children}
 {if count == "1"}
 <ul class="agent">
 <li class="name">{title}</li>
 <li class="phone">{phone}</li>
 <li class="mail">{agent_email}</li>
 </ul>
 {if:else}
 <div class="accordion">
 <h3 class="name">{title}</h3>
 <div>
 <ul class="agent">
 <li class="phone">{phone}</li>
 <li class="mail">{agent_email}</li>
 </ul>
 </div>
 </div>
 {/if}
 {/exp:playa:children}

What I am seeing is single realtors being listed fine, but when there are two realtors it lists the first one as a single and puts the second realtor in the accordion.

Any help would be great, I have been trying to figure this out for a while and can't seem to quite get there.

Thanks!

4

Have you tried using total_results instead of count?

{exp:playa:children}
    {if total_results == "1"}
        <ul class="agent">
            <li class="name">{title}</li>
            <li class="phone">{phone}</li>
            <li class="mail">{agent_email}</li>
        </ul>
    {if:else}
        <div class="accordion">
            <h3 class="name">{title}</h3>
            <div>
                <ul class="agent">
                    <li class="phone">{phone}</li>
                    <li class="mail">{agent_email}</li>
                </ul>
            </div>
        </div>
    {/if}
{/exp:playa:children}
| 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.