Skip to content

Using setcontent with orderby doesn't return results #1523

@milosa

Description

@milosa

Contenttype:

packages:
    name: Pakketten
    singular_name: Pakket
    fields:
        name:
            label: Naam
            type: text
        price:
            label: Prijs
            type: number
            mode: integer
            step: 1
        order:
            type: number
            mode: integer
            step: 1
            label: Volgorde
    viewless: false

When I use {% setcontent packages = 'Pakketten' orderby 'order' %}, packages has no items.
When I use {% setcontent packages = 'Pakketten' %}, it has the items I expect (but obviously not ordered the way I want)

I used printquery on both.

The first one shows:

SELECT content FROM Bolt\Entity\Content content LEFT JOIN content.fields fields_order_1 LEFT JOIN fields_order_1.translations translations_order_1 WHERE content.contentType = :ct0 AND content.status = :status_1 AND fields_order_1.name = :order_1 AND translations_order_1.locale = :order_1_locale ORDER BY lower(translations_order_1.value) ASC
ct0: pakketten
status_1: published
order_1_locale: en
order_1: order

The second one shows:

SELECT content FROM Bolt\Entity\Content content WHERE content.contentType = :ct0 AND content.status = :status_1 ORDER BY content.publishedAt DESC
ct0: pakketten
status_1: published

I noticed that in the first query, order_1_locale is set to en, whereas my site is configured to be nl. nl is the only locale.

Details

Question Answer
Relevant Bolt Version 4.0 master (dev-master 781cd66)
Install type Composer install
PHP version 7.4.7
Web server symfony

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions