1

I'm making lookbooks:

Each look has (parent) contains one or more items (children). Each item has a brand.
E.g. Picture 1 where a girls wears pants of Brand A, t-shirt of Brand B and a jacket of Brand A.

In my overview of Brand A, i want to show all pictures where the girls wears Brand A once. With this code Picture 1 appears 2x in the overview. How can I get this picture only show up once?

I must be looking at code for too long. I'm sure there's a simple solution to this. Thank you for your help.

{exp:channel:entries channel="items" search:item_brand="{last_segment}" dynamic="no"}
    {exp:playa:parents channel="looks" require_entry="yes"}
                    <img src="{look_image}" alt="{title}">
    {/exp:playa:parents}
{/exp:channel:entries}
0

I would use Stash for this, and split your data fetching from your markup assembly. Specifically, the get_list tag has a unique="yes" parameter that would allow you to only output each 'look' once:

{exp:stash:set_list name="looks" parse_tags="yes"}
  {exp:channel:entries channel="items" search:item_brand="{last_segment}" dynamic="no"}
    {exp:playa:parents channel="looks" require_entry="yes"}
       {stash:the-title}{title}{/stash:the-title}
       {stash:the-image}{look_image}{/stash:the-image}
    {/exp:playa:parents}
  {/exp:channel:entries}
{/exp:stash:set_list}

<ul>
   {exp:stash:get_list unique="yes" name="looks"}
      <li><img src="{the-image}" alt="{the-title}"></li>
   {/exp:stash:get_list} 
</ul>
1
  • Thanks a lot! I just had to add parse_depth="2" to set_list
    – LeenVdP
    Sep 30 '13 at 11:56

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.