0

We're using the relationship field to output the "brand" of items, on the listing page we want to output all of the "brands" so that we can filter by brand, however by default the tag outputs each and every items "brand". We would like to limit it so that it doesn't show the same brand twice, it this possible?

Our current code looks like this:

    <ul>
      <li class="all"><a href="#all">All brands</a></li>
      {exp:channel:entries channel="products" category_group="1"}
      <li>
        {product_label}
        <a href="#product_label:url_title">
          {product_label:title}
        </a>
        {/product_label}
      </li>
      {/exp:channel:entries}
    </ul>

Any ideas much appreciated!

1

I see 2 options, firstly you might be able to acheive this with Stash, make a list of the product_label entry id's and check this list as you print out the next one, if its in the list don't print.

The second option is a bit more heavy. We could use a single PHP query to get your list of product label titles, then iterate the products channel as normal, using the PHP query result to control the output of the relationship fields. If you want to go down this route comment and I'll try to find a moment to write an example for you.

1
  • Happy days! I've not used Stash much and feel I'm missing out on a quality component for EE these days. Glad it was an easy fix and happy to have helped! Tnx for marking the answer too, really helps othes with similar problems :)
    – Blatant
    Jun 10 '15 at 13:02

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.