Draft items in Pages Field

I am having trouble getting draft items to show in a “pages” panel field. The goal is to aggregate “video” pages from anywhere in the content tree and have them available within a “pages” input, whether or not they are draft.

Trying:
query: site.index(true).template("video")

But this only yields non-draft entries, same as
query: site.index.template("video")

I’ve also tried via a custom collection:
query: kirby.collection("all_videos")

…alongside a custom collection with:
return function ($site) { return $site->index(true)->template('video'); };

While this returns all videos, draft or otherwise, when using the collection in a template, the blueprint query still only returns non-draft items.

Thanks in advance for any help / ideas / experience anyone can provide!

Works for me (tested with 3.2.4-rc1, but should work with 3.2.3 at least as well, I guess). What is your Kirby version?

Tried moving to 3.2.4-rc1 but still no dice.

Some other tests I’ve tried:

query: site.index(true).drafts() returns drafts of all types
query: site.index(true).template("video") returns only non-draft videos
query: site.index(true).template("video").drafts() returns nothing

I’ve also tried ...filterBy("template","video")... but the result is the same.

Finally I’ve tried removing all plugins and disabled our custom “video” model but still no luck.

It seems that something in how template() / filterBy() operate in a blueprint query is causing our drafts to be dropped. Any further ideas?

This is weird. Are there even any drafts with the video template?

Indeed there are, and I can see them in the site.index(true).drafts() example, but not when I add the template filter.

But then they should appear with site.index(true) without adding drafts().

I have no idea what might be going wrong and probably would have to see the project.

There’s a lot of content on the site, so site.index(true) takes quite a while to load, but does NOT show the video drafts…yet site.index(true).drafts does(!).

Before I drag you further into this I’m going to try to set up a test environment with a totally clean install of Kirby and the simplest of content trees. This is a real head-scratcher.

Sounds like a good idea.

Note that if you use query: site.index(true).drafts it does not return first level drafts, if you want the full index, you have to use site.index(true).

Just for my own edification, can you point me to where in Kirby’s Git repo the query string interpretation happens?

  • /kirby/config/fields/mixins/pagepicker.php
  • /kirby/src/Cms/ModelWithContent.php #390
  • /kirby/src/Toolkit/Str.php #525
  • Query class, /kirby/src/Toolkit/Query.php