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.