3

I have the following code:

{exp:channel:entries channel="blog" require_entry="yes" limit="1"}
<div class="row related-articles">
    <div class="grid_12">
        <h2>Related Articles</h2>
        <ul class="unstyled inline">
            {exp:playa:children entry_id="{entry_id}"}
                {cf_general_related}
                <li class="grid_3 alpha omega">
                    <h3>{title}</h3>
                    <img src="#" alt="#"/>
                    <span class="clear"></span>
                </li>
                {/cf_general_related}
            {/exp:playa:children}
        </ul>
    </div>
</div>
{/exp:channel:entries}

The problem I'm finding here is, my related entries are outputting in multiples, so if I have 2 relative entries, I get 4 results in the template, if I have 4 relative entries, I get 16 items output. And each item repeats so many times.

Why?

  • What's the name of your playa field? What happens if you remove {exp:playa:children entry_id="{entry_id}"} and {/exp:playa:children}? – Stephen Callender Nov 28 '12 at 13:52
  • Is {cf_general_related} the name of your Playa field in your Blog channel? – Derek Hogue Nov 28 '12 at 13:53
  • Please make sure to select your answer as the correct answer. – Anna_MediaGirl Dec 15 '12 at 2:24
4

You are getting duplicate content cause playa is being called twice

First by (the direct call to the playa module)

{exp:playa:children field="cf_general_related"}

Secondly by (the field name tag pair option)

{cf_general_related}
    <li>..</li>
{/cf_general_related}

which produces

{exp:playa:children field="cf_general_related" entry_id="{entry_id}"}

I prefer field name tag pair (keeps the template clean)

{cf_general_related}{/cf_general_related}

*assuming that your playa field is {cf_general_related}

P.S. Upgrade to the latest version of Playa as there are some issues that have been addressed, one annoying one is

-Fixed a bug where closing Playa module tags would show up on the front end of the site

| improve this answer | |
2

Everything is sorted now. It turns out I only needed to update Playa to the latest version, and all my troubles disappeared.

| improve this answer | |
1

You need to set up your entry something like this:

{exp:channel:entries channel="fact_sheets" limit="1" disable="categories|category_fields|member_data|pagination" }

 {exp:playa:children field="press_photos" }

      {if full_size_photo == ""}

         <img src="{press_thumbnail}" alt="{title}" />

      {if:else}

         <a href="{full_size_photo}"><img src="{press_thumbnail}" alt="{title}" /></a>

      {/if}

         <p>{caption}</p>

  {/exp:playa:children}

{/exp:channel:entries}

You pull the entry in with the channel entries and you reference the field in the Playa tag.

| improve this answer | |
0

I think it's because you nested 2 playa tags:

{exp:playa:children entry_id="{entry_id}"}
{cf_general_related}

The corrected syntax is:

{exp:playa:children field="cf_general_related"}
    <li>...</li>
{/exp:playa:children}

You can find more info in the docs: http://pixelandtonic.com/playa/docs/templates#playa:children

EDIT:

Seems like you're just trying to get the related fields of your entry. All you need to do is this:

{cf_general_related}
    <li>..</li>
{/cf_general_related}
| improve this answer | |
  • When I try this, I get the title's and data for the item itself, as passed in entry_id, and not the related items as expected? – josef.van.niekerk Nov 28 '12 at 13:57
  • take a look at my updated answer, that should do it. – janvl Nov 28 '12 at 14:18

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.