You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to create prev/next links for entries that are filtered by a custom field (a lightswitch field in this case).
The query is executed without respecting the custom field.
This seems to be due to a bug in the implementation of craft\base\Element -> _getRelativeElement.
In line 2158 when you do $query = clone $criteria; the behaviors of the object don't get cloned, so they get lost.
You can try this out by changing line 2169 from$elementIds = $query->ids(); to $elementIds = $criteria->ids(); which will produce the expected result (prev/next links are filtered by custom field), but that's not a generally valid solution of course.
Steps to reproduce
I'm querying the field like this (with sectionTitle and customField replaced by actual existing values): {% set params = craft.entries.section('sectionTitle').customField(0).orderBy('title desc') %} {% set prevEntry = entry.getPrev(params) %}
Instead of the prevEntry being populated with the entries filtered by customField, all entries from the section are taking into accord.
Additional info
Craft version: Craft Pro 3.0.12
PHP version: 7.1.11
Database driver & version: MySQL 5.5.5
Plugins & versions: irrelevant
The text was updated successfully, but these errors were encountered:
Description
I try to create prev/next links for entries that are filtered by a custom field (a lightswitch field in this case).
The query is executed without respecting the custom field.
This seems to be due to a bug in the implementation of craft\base\Element -> _getRelativeElement.
In line 2158 when you do
$query = clone $criteria;
the behaviors of the object don't get cloned, so they get lost.You can try this out by changing line 2169 from
$elementIds = $query->ids();
to$elementIds = $criteria->ids();
which will produce the expected result (prev/next links are filtered by custom field), but that's not a generally valid solution of course.Steps to reproduce
{% set params = craft.entries.section('sectionTitle').customField(0).orderBy('title desc') %}
{% set prevEntry = entry.getPrev(params) %}
Additional info
The text was updated successfully, but these errors were encountered: