-
-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Milestone
Description
Description
The code I have written to populate a blog with a mix of drafts and published articles prefixed with the value from the date field for sorting fails, all pages are drafts. The isDraft prop is documented here https://getkirby.com/docs/reference/objects/cms/page/create.
To reproduce
composer create-project getkirby/plainkit- Change dir into the project
composer require fakerphp/faker- Create a file
seed-blog.phpin the root of the project with the following:
<?php
use Kirby\Cms\Page;
require 'kirby/bootstrap.php';
$app = new Kirby();
$app->impersonate('kirby');
$blog = $app->site()->find('blog');
$faker = Faker\Factory::create();
$faker->seed(12345);
for ($i = 0; $i < 100; $i++) {
$date = $faker->dateTimeThisDecade();
$page = Page::create([
'parent' => $blog,
'slug' => $slug = join('-', $faker->words(5)),
'isDraft' => $faker->boolean(25),
'template' => 'article',
'content' => [
'title' => $faker->sentence(),
'date' => $date->format('Y-m-d H:i:s'),
'body' => $faker->paragraphs(5, true),
],
]);
}
- Create
content/blogfolder - Create
site/blueprints/pages/article.ymlwith the following:
num: '{{ page.date.toDate("Ymd") }}'
fields:
date:
type: date
body:
type: textarea
php seed-blog.php
Kirby Version
3.9.1
Metadata
Metadata
Assignees
Labels
No labels