Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs on querying entry statuses #1340

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions content/collections/docs/4-to-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,53 @@ If you use this `{{ glide filename="" }}` parameter, you'll need to remove remov

If you are hot-linking to any images rendered with manually set filenames in this way, you'll also need to correct those links.

### Entries may now only be queried by a single status
**Affects any apps or addons filtering entries by `status`.**

Previously, when querying entries, you could use *any* condition to filter entries.

However, in v5, as part of improvements to how statuses work behind the schenes, statuses can now only be filtered using the `is` / `equals` conditions, and the `whereStatus` query method. Some examples:

Collection tag:
```antlers
{{ collection:blog status:in="published" }} {{# [tl! --] #}}
{{ collection:blog status:is="published" }} {{# [tl! ++] #}}
```

PHP:
```php
Entry::query()
->where('collection', 'blog')
->where('status', 'published') // [tl! --]
->whereStatus('published') // [tl! ++]
->get();
```

REST API:
```php
/api/collections/blog/entries?filter[status:in]=published // [tl! --]
/api/collections/blog/entries?filter[status]=published // [tl! ++]
```

GraphQL API:
```graphql
{
entries(
collection: "blog"
filter: {
status: { in: "published" } #[tl! --]
status: "published" #[tl! ++]
}
) {
data {
title
}
}
}
```

Let us know if you need to query by multiple statuses by opening a [GitHub issue](https://github.com/statamic/cms).

## Zero impact changes

These are items that you can completely ignore. They are suggestions on how to improve your code using newly added features.
Expand Down
10 changes: 2 additions & 8 deletions content/collections/tags/collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,8 @@ There are several different ways to use this filtering parameter. They are expla
By default, only `published` entries are included. Entries can be queried against `draft`, `scheduled`, or `expired` status with [conditions](#conditions) on `status` like this:

```
// Include draft entries
{{ collection:blog status:in="published|draft" }}

// Only include expired entries
{{ collection:blog status:is="expired" }}

// Exclude published entries
{{ collection:blog status:not_in="published" }}
// Only include published entries
{{ collection:blog status:is="published" }}
```

:::tip
Expand Down