Skip to content

get random content not working #1596

@peterboorsma

Description

@peterboorsma

Fetching random records does not work as expected.

I tried 2 ways with a freshly installed RC27 clearing cache after every change in the code.

First:
{% setcontent random = 'pages' limit 2 printquery %}

Returns 6 pages (the max amount set in config.yaml = listing_records: 6) but not randomly.

Printquery

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

    ct0: pages
    status_1: published

Second:

{% setcontent pages = 'pages/random/2' printquery %}

Returns 0 results

Printquery

     SELECT content FROM Bolt\Entity\Content content WHERE content.contentType = :ct0 AND content.status = :status_1 AND (content.id IN(SELECT content_2.id FROM Bolt\Entity\Content content_2 INNER JOIN content_2.fields fields_2 INNER JOIN fields_2.translations translations_2 WHERE JSON_EXTRACT(translations_2.value, '$[0]') = :slug_1 AND fields_2.name = :field_2)) ORDER BY content.publishedAt DESC
        ct0: pages
        slug_1: random,2
        status_1: published
        field_2: slug

I expected to get 2 random pages with both queries, of course :)


Bolt 4.0.0 RC27

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