0

I have some template code that used to work:

{exp:playa:children field="blog_related_entry" limit="5"}
{if count == 1}
<ul class="no-bullet">
  <li>Related Entries</li>
{/if}
  <li><a href="{site_url}blog/{url_title}" title="{title}">{title}</a></li>
{if count == total_results}
</ul>
{/if}
{/exp:playa:children}

I'm not sure when it broke, but with EE 2.8.1, Playa 4.5.2 this lists out the parent entry as a relationship 5 times, or 100 if there is no limit set. (I upgraded from Playa 4.1 in an attempt to solve the problem, I can't upgrade EE due to other issues.)

Any idea what's happening here?

-- Andris (accepted answer below) found it was a combination of needing to set var_prefix, entry_id and change the EE template tags - namely enclose the IF conditional fields in quotes and curly braces:

{exp:playa:children field="blog_related_entry" var_prefix="related_blog" entry_id="{entry_id}"}
{if "{related_blog:blog_published}"=="Yes"}
{if "{related_blog:count}" == 1}
<ul class="no-bullet">
  <li>Related Entries</li>
{/if}
  <li><a href="{site_url}blog/{related_blog:url_title}" title={related_blog:title}>{related_blog:title}</a></li>
{if "{related_blog:count}" == "{related_blog:total_results}"}
</ul>
{/if}
{/if}
{/exp:playa:children}

1 Answer 1

0

You should be using the var_prefix parameter to avoid field naming conflicts. Try something like

{exp:playa:children field="blog_related_entry" limit="5" var_prefix="blog_entry"}
    {if count == 1}
        <ul class="no-bullet">
        <li>Related Entries</li>
    {/if}
    <li><a href="{site_url}blog/{blog_entry:url_title}" title="{blog_entry:title}">{blog_entry:title}</a></li>
    {if count == total_results}
        </ul>
    {/if}
{/exp:playa:children}
2
  • This doesn't have any effect. I've just noticed allthough {title} is showing the parent title, {entry_id} within exp:playa:children displays entry IDs from different entries, some not in the channels specified in the field setup. Mar 16, 2016 at 10:58
  • This was in fact part of the problem (rest explained in original question), and Andris also solved the rest. Thank you! Mar 18, 2016 at 10:57

Your Answer

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

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