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

Duplicate elements being displayed with relatedTo param #1635

Closed
connor-baer opened this issue Apr 17, 2017 · 0 comments
Closed

Duplicate elements being displayed with relatedTo param #1635

connor-baer opened this issue Apr 17, 2017 · 0 comments
Assignees
Labels

Comments

@connor-baer
Copy link

connor-baer commented Apr 17, 2017

Description

There seems to be an issue with the relatedTo query param in Craft 3. When I try to get all categories/tags related to the entries from one section, the categories/tags are displayed multiple times. Specifically, the categories/tags are displayed for each entry they've been assigned to. The desired behaviour would be each category/tag is only output once, right?

Steps to reproduce

  1. Create a few entries in a section and assign categories to them. Make sure to assign one category to multiple entries.
  2. Put the following code into a template:
{% set posts = craft.entries.section('sectionHandle').limit(null) %}
{% set categories = craft.categories.relatedTo(posts) %}

{% for category in categories %}
    {{ category.title }}
{% endfor %}
  1. The title of a category will appear for each post it's been assigned to, i.e. multiple times. It should only appear once, right?

Additional info

  • Craft version: Craft 3-beta.12
  • PHP version: 7.1.4
  • Database driver & version: MySQL 5.7.17
  • Plugins & versions: Element Api 2.0.1
@brandonkelly brandonkelly self-assigned this Apr 18, 2017
@brandonkelly brandonkelly changed the title [Bug] Issue with relatedTo param in Craft 3 Duplicate elements being displayed with relatedTo param Apr 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants