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

context being ignored? #31

Closed
i-just opened this issue Mar 11, 2021 · 6 comments
Closed

context being ignored? #31

i-just opened this issue Mar 11, 2021 · 6 comments

Comments

@i-just
Copy link

i-just commented Mar 11, 2021

I'm grabbing some related entries like this:

{% set tagsFieldHandle = 'centreArticlesTags' %}
{% set related = craft.similar.find({ element: entry, context: entry[tagsFieldHandle], criteria: craft.entries.limit(3) }) %}

Up until version 1.0.6, Similar was only returning entries that actually used 'centreArticlesTags' field. Since version 1.1.0, the plugin is returning entries from various other sections that don't use that tags field at all.

I can limit it to just the section(s) I want via criteria, but it seems to me that this change in behaviour might not be intentional? I mean I'm not sure what it now actually uses to figure out if another entry is related since it's looking through entries that don't have the tags group I specified in context? Was this change in behaviour intentional?

@khalwat
Copy link
Contributor

khalwat commented Mar 11, 2021

Very well could be an unintentional side-effect. Will have a look

@khalwat
Copy link
Contributor

khalwat commented Mar 11, 2021

Potentially related to: #29 (comment)

@aurexs
Copy link

aurexs commented Mar 18, 2021

I'm having the same problem.

When the entry has tags that do not have another related entry, it returns entries from other sections. Even if it is limited by section via criteria, it returns multiple inputs (from the same section) with count = NULL.

In context I must pass the IDs of the tags because if I use entry.tags it returns entries that do not have related tags either (with count = NULL).

I'm using version 1.1.1

{% set tagIds = [] %}
{% for tag in entry.servicioTags %}
  {% set tagIds = tagIds|merge([tag.id]) %}
{% endfor %}

{% set serviciosCriteria = craft.entries
                  .section('servicios')
                  .with([
                    'imagen',
                    'categoriaPerfil',
                    'servicioTags'
                  ]).limit(4) %}

{% set serviciosRel = craft.similar.find({ element: entry, context: tagIds, criteria: serviciosCriteria }) %}

@khalwat
Copy link
Contributor

khalwat commented Mar 19, 2021

Addressed in: 47aa0bd

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-similar": "dev-develop as 1.1.2”,

Then do a composer update

@khalwat
Copy link
Contributor

khalwat commented Mar 23, 2021

@i-just @aurexs you able to try this?

@i-just
Copy link
Author

i-just commented Mar 23, 2021

@khalwat it seems to be back to how it used to work; context is limiting finding related/similar entries to the ones that have the context field in them; thanks for fixing!

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

No branches or pull requests

3 participants