bolt: [BUG] - setcontent does a wrong inference when using singular content type slug
Given Using :
{% setcontent banner = 'slider' where { status: 'published' } %}
return an array of sliders… However "slider’ is the singular slug of the “sliders” content type.
sliders:
name: Sliders
slug: sliders
singular_name: slider
singular_slug: slider
fields: ....
while according to the documentation :
Bolt tries to make an assumption about how you want to use it, based on what you’re requesting. By default, an array is returned, unless one of the following is the case: … {% setcontent foo = ‘page’ where { … } %}: If ‘page’ is the singular slug of the contenttype ‘pages’, Bolt assumes you only need one. …
when i use the “returnsingle” meta :
{% setcontent banner = 'slider' where { status: 'published' } returnsingle %}
I get only one result, as expected.
It seems the bug is in the Storage.php within the parseTextQuery method.
I think we should add a check wether the singular or the plural form of the content type is used… and assume the user knows what is he doing 😃
- Relevant Bolt Version: [ 2.2.17 ]
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (14 by maintainers)
Commits related to this issue
- Remove inference from docs See bolt/bolt#5067 — committed to bolt/docs by SahAssar 8 years ago
how about
{% setone thing = 'pages/1' %}and{% setmultiple things = 'pages/10' %}and let setcontent be backwards compatible.{% setcontent pages = 'pages' %}