Craft CMS Asked on September 4, 2021
A Craft (3.4 Pro) website has setup two sites, one for each language. There are entries in a section that are enabled and others that are disabled for each language.
I want to get a list of all the entries, regardless of whether they are enabled or not.
I know there is a enabledForSite
parameter but this can be set to either true
or false
but not both.
For example the query below returns only enabled entries.
{% set items = craft.entries({
section: 'works',
enabledForSite: true,
status: [
'live', 'pending', 'disabled', 'expired'
]
}).all() %}
How can I get a list that contains both enabled
and disabled
entries?
With the help of Oli from Craft, it turns out the solution is simpler than I thought:
{% set items = craft
.entries()
.section('works')
.anyStatus()
.all()
%}
This returns all entries, enabled and disabled.
Correct answer by Panos Spiliotis on September 4, 2021
From a quick look at the code, I think you can pass enabledForSite: [true, false]
to get both the enabled and disabled entries. So in your case:
{% set items = craft.entries({
section: 'works',
enabledForSite: [true, false],
status: [
'live', 'pending', 'disabled', 'expired'
]
}).all() %}
Answered by Marion Newlevant on September 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP