statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

filter collections with taxonomies #2523

Closed Oleafeon closed 4 years ago

Oleafeon commented 4 years ago

Describe the bug I have taxonomies that i use to filter the collection news, but when i look at it on the frontend it does not work. I have looked for an solution online but did not found it anywhere

Screenshots this is what i tried

Template

{{ collection :from="news" :taxonomy="news_filter" }}
     <div>
         {{ assets:featured_image }}
             <img src="{{ url }}" class="img-fluid" alt="{{ alt }}">
         {{ /assets:featured_image }}
         <div class="slider__text">
             <h4>{{ title }}</h4>
             <p>
                 {{ featured_text }}
             </p>
             <a href="{{ url }}" class="btn--green">Lees meer</a>
           </div>
       </div>
{{ /collection }}

Fieldset

news_featured:
  display: 'News featured'
    fields:
      header_title:
        display: 'Header title'
        type: text
      news:
        type: collections
        display: News
        max_items: 1
      news_filter:
        taxonomy: tags
        type: taxonomy
        display: 'News filter'

Markdown

type: news_featured
  news: news
  header_title: 'Latest News'
  news_filter:
    - tags/business-club
    - tags/charity

Environment details (please complete the following information):

Oleafeon commented 4 years ago

I have discovered that it does work if you have max_items on 1 for the taxonomies

news_filter:
    taxonomy: tags
    type: taxonomy
    display: 'News filter'
    max_items: 1

Is this true cause i need it to work for when you can select multiple

Oleafeon commented 4 years ago

I have fixed it I have found out that when u use the standard taxonomies: true on the collections it does work, now i can also remove max_items

news_filter:
    taxonomy: tags
    type: taxonomy
    display: 'News filter'