# Virtual page from database: drafts not showing in panel

**URL:** <https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146>\
**Category:** Questions\
**Tags:** v3\
**Created:** [May 2, 2021, 1:12pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146 "2021-05-02T13:12:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eliott](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@Eliott](https://forum.getkirby.com/u/Eliott)\
**Post date:** [May 2, 2021, 1:12pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146/1 "2021-05-02T13:12:26Z")

</div>

I have just finished a project using a database. Everything is working fine. In the blueprints for collections I first used one section showing all records combined. As a last step I now want to turn these collections blueprints into the Kirby-style three sections _Drafts, Unlisted,_ and _Listed._ But I fail to list the drafts.

Blueprint:

```
sections:
  collection1:
    headline: Drafts
    type: pages
    status: draft
    template: item
  collection2:
    headline: Unpublished
    type: pages
    status: unlisted
  collection3:
    headline: Published
    type: pages
    status: listed

```

This is the code in the Item class:

```
  public function isDraft(): bool {
    return $this->content()->data()['status'] === 'draft';
  }

  public function isListed(): bool {
    return $this->content()->data()['status'] === 'listed';
  }

  public function isUnlisted(): bool {
    return $this->content()->data()['status'] === 'unlisted';
  }

```

When I echo the value of _$this-\>content()-\>data()[‘status’]_ in these three methods, this is what I get for _isListed()_ and _isUnlisted():_

> ```
> draft
> draft
> listed
> listed
> listed
> unlisted
> draft
> listed
> unlisted
> draft
> 
> ```

And for _isDraft()_ the result is:

> ```
> listed
> listed
> listed
> listed
> 
> ```

… which does not make sense, as it only queries the four ‘listed’ records instead of all ten.

It seems that when _isDraft()_ is called, some filtering towards the ‘listed’ ones has already been applied, but I have not been able to find out where this is happening.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 2, 2021, 1:53pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146/2 "2021-05-02T13:53:11Z")

</div>

> [@Eliott](#):
>
> ```auto
> public function isListed(): bool {
> return $this->content()->data()['status'] === 'listed';
> }
> 
> public function isListed(): bool {
> return $this->content()->data()['status'] === 'unlisted';
> 
> ```

Those two are duplicated with different results (should be unrelated to the drafts, but still)

---

<div class="post-metadata">

**Author:** ![Eliott](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@Eliott](https://forum.getkirby.com/u/Eliott)\
**Post date:** [May 2, 2021, 3:30pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146/3 "2021-05-02T15:30:23Z")

</div>

Thank you. I corrected it in the OP.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 2, 2021, 3:42pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146/4 "2021-05-02T15:42:29Z")

</div>

Are drafts() re-defined in your parent page model?

---

<div class="post-metadata">

**Author:** ![Eliott](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@Eliott](https://forum.getkirby.com/u/Eliott)\
**Post date:** [May 2, 2021, 4:11pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146/5 "2021-05-02T16:11:00Z")

</div>

Thank you very much for that tipp. It works when I add this to the parent page:

```
  public function drafts() {
    return $this->children()->filter('status', 'draft');
  }
```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 2, 2021, 4:12pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146/6 "2021-05-02T16:12:34Z")

</div>

It might make sense to also redefine `childrenAndDrafts()`, just in case, you never know if you need it or not.

---

<div class="post-metadata">

**Author:** ![Eliott](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@Eliott](https://forum.getkirby.com/u/Eliott)\
**Post date:** [May 2, 2021, 4:12pm UTC](https://forum.getkirby.com/t/virtual-page-from-database-drafts-not-showing-in-panel/22146/7 "2021-05-02T16:12:34Z")

</div>

I think I’m going to separate the creation of _children()_ and _drafts()_, despite that the data is coming from the same table in the database.
