1

one called "crops" one is named "products".

Crops linked to products, through a playa field for the products channel.

At the moment my tag produces a list of crops but many are repeated.

When populating a crops menu, I want to query those crops who are linked to a product. This way, crops for which we dont have products assigned aren't listed. I want a unique entry for each crop that has 1 or more products associated to it.

Any ideas?

Update

Here is the code I left out last time...

{if segment_2=="crops"}
<div class="box plants">
    <h2>Φυτά</h2>
<select>
    <option {if segment_2==""}selected="selected"{/if} value="/index.php/products/">όλa</option>
        {exp:channel:entries channel="products" orderby="title" sort="asc" dynamic="no"}
            {exp:playa:children channel="crops"}
                {if count>0}
                    <option {if segment_3==url_title}selected="selected" {/if} value="/index.php/products/crops/{url_title}">{title}</option>
                {/if}
            {/exp:playa:children}
        {/exp:channel:entries}
</select>
</div>
{/if}

The playa relationship is a field in products channel that links to entries (fieldname={crops})in the crops channel. Not sure whether this is revers relationship or not.

2
  • A little more info would be helpful. What is your current template code, what are the custom fields named? Which one is the playa relationship? Will this be a reverse relationship or a regular one? – CreateSean Jul 8 '13 at 16:36
  • Hey CreateSean, I've updated my query as per your request! let me know if I can provide more details! – Dimitri Shukuroglou Jul 9 '13 at 7:37
1

I had exactly this problems, and I used Nested Entries instead. Maybe this can help you too.

{exp:channel:entries channel="country"}
    {title}
    {exp:nested:prep_vars var_prefix="nested_"}
        {exp:nested:entries channel="office" dynamic="off" search:cf_office_country="{title}"}
            Office: {nested_title}
        {/exp:nested:entries}
    {/exp:nested:prep_vars}
{/exp:channel:entries}
1
  • This is great! Has helped loads and has allowed me to really cool stuff with nested playa fields. Thank you ianisted! – Dimitri Shukuroglou Jul 17 '13 at 10:05

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.