Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy listing with collection param returns all terms #1684

Closed
mikemartin opened this issue Apr 15, 2020 · 14 comments · Fixed by #3870
Closed

Taxonomy listing with collection param returns all terms #1684

mikemartin opened this issue Apr 15, 2020 · 14 comments · Fixed by #3870

Comments

@mikemartin
Copy link

mikemartin commented Apr 15, 2020

Bug Description

We have a collection with one entry that is tagged with a single term. When I pass the collection param, I would expect to only have that single term return however it returns all terms.

{{ taxonomy:levels collection="math-zone" }}
      <a href="{{ url }}">{{ title }}</a>
{{ /taxonomy:levels }}

It looks like the collection parameter is queried here but then it returns all terms. https://github.com/statamic/cms/blob/master/src/Tags/Taxonomy/Terms.php#L36

Statamic version: 3.0.0.-beta-26

PHP version: 7.{?}

Install method (choose one):

  • Fresh install from statamic/statamic
  • Starter kit
  • Existing Laravel app
  • Other (please explain this magic!)
@jasonvarga
Copy link
Member

How many terms are in that taxonomy? Are they all being output?

@edalzell
Copy link
Contributor

edalzell commented Apr 15, 2020

There are 2 terms, but this entry has only one. However regardless of which term route we are on, this entry is returned @jasonvarga

@edalzell
Copy link
Contributor

What I DO see is that when are NO terms, all are shown, like here: https://challengeteacher.online/math-zone/levels/primary there should be nothing shown.

The code we're using is:

      {{ collection :from="segment_1" }}
        <li class="flex flex-1">
          {{ partial:activities/card }}
        </li>
      {{ /collection }}

@jasonvarga
Copy link
Member

The code in the initial issue description is a taxonomy tag. Now you're showing me a collection tag. I'm confused. 🤔

@edalzell
Copy link
Contributor

Ya sorry I'm confused too, let me regroup and report, feel free to delete my comments. I gotta understand how we're using the taxonomies.

@mikemartin
Copy link
Author

Hey @jasonvarga,
If you visit @edalzell site at http://challengeteacher.online/math-zone you'll see that the Math Zone collection has one entry, yet both terms are listed.

Levels Taxonomy
/taxonomies/level.yaml

title: Levels
blueprints:
  - level

Taxonomy terms in /taxonomies/levels:
intermediate.yaml
primary.yaml

Collection entry in /collections/math-zone/:
2020-04-13.a-problem-4-you.md

---
title: 'A Problem 4 You'
summary: 'Come up with the numbers from 1 to 15 using four fours'
description:
  -
    type: paragraph
    content:
      -
        type: text
        text: 'Did you know you can make a lot of numbers with exactly four fours?'
  -
    type: paragraph
    content:
      -
        type: text
        text: 'Using addition, subtraction, multiplication, division, parentheses (to show what to do first) and square roots, see if you can make equations that use four fours to come up with the numbers from 1 to 15.'
  -
    type: paragraph
    content:
      -
        type: text
        text: 'For example 4÷4+4-4=1 '
  -
    type: paragraph
    content:
      -
        type: text
        text: 'Llama''s hint: remember that the square root of 4 is 2. '
levels:
  - intermediate
updated_by: 4385e51a-052c-4af4-a564-3a9690f4003b
updated_at: 1586804054
id: 6f400cb2-5999-45fe-bd14-000ab8379c21
---

@jasonvarga
Copy link
Member

Did you work this out?

@jasonvarga
Copy link
Member

Hey there, we haven’t heard back on this for a while so I’m going to need to close the issue to help us stay organized. You can always reply with more info so we can reopen it or feel free start a fresh one anytime. Either is fine by us!

@JonKaric
Copy link
Contributor

JonKaric commented May 11, 2021

I'm getting this behaviour too. I've got a taxonomy with ~15 terms. On a collection with no entries, every term is still being output. {{ taxonomy:gallery collection="screencaps" sort="sort_order" as="entries" }}

I think it's just ignoring the collection param entirely, it happens on all of my collections. I've tried adding more piped collections, using a variable etc. Still the same result.

Could we reopen this?

EDIT: I'm on a custom route, not one that Statamic auto-generates

Statamic 3.1.13 Pro
Laravel 7.30.4
PHP 7.4.16
statamic/migrator dev-master
statamic/seo-pro 2.2.1

@jasonvarga jasonvarga reopened this May 13, 2021
@zgambs
Copy link

zgambs commented May 24, 2021

We have been experiencing this same issue. {{ taxonomy:tags collection:is="blog" limit="50" }}

Instead of only getting terms in the blog collection the output is all of our tags terms.

NOTE: I am not on one of the auto-magically created routes that is defined here: https://statamic.dev/taxonomies#routing

  Statamic 3.0.49 
  Laravel Framework 7.30.4
  PHP 7.4.16

@jasonvarga
Copy link
Member

Are you doing collection:is="blog" or collection="blog"? Do the second one.

@zgambs
Copy link

zgambs commented May 24, 2021

@jasonvarga I have tried both and both give the same issue!

@zgambs
Copy link

zgambs commented Jun 3, 2021

I am unsure if this is directly related or not, but filtering taxonomy terms by collection on magically created taxonomy routes is also not working. If I create a /resources/views/blog/index.antlers.html view and place either of the two code snippets into that file:

{{ terms }}
<li>{{ title }}</li>
{{ /terms }}
{{ tags }}
<li>{{ title }}</li>
{{ /tags }}

I would expect the tag terms that output to only be terms used in blog collection entries, but the output includes all tags. Even tags that are not attached to any entries at all.

Some more detailed discussion about this can be found here: https://discord.com/channels/489818810157891584/489819906540568593/850100960214515753

Screen Shot 2021-06-03 at 6 16 25 PM

@zgambs
Copy link

zgambs commented Jun 14, 2021

This looks related: #1993

Curious what other information could be given in order to have some motion on either this issue or the one linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants