Skip to content

Instantly share code, notes, and snippets.

@pedroborges
Created July 8, 2019 12:31
Show Gist options
  • Save pedroborges/f7e2903588eabb602335fbe8dd0dbf45 to your computer and use it in GitHub Desktop.
Save pedroborges/f7e2903588eabb602335fbe8dd0dbf45 to your computer and use it in GitHub Desktop.
How to add Kirby 3 file template to Kirby 2 images
<?php
require __DIR__ . '/kirby/bootstrap.php';
// echo (new Kirby)->render();
$items = page('blog')->children();
foreach ($items as $item) {
if ($i = $item->cover()->toFile()) {
$i->update([
'template' => 'cover',
]);
}
foreach ($item->gallery()->split(',') as $image) {
if ($i = $item->file($image)) {
$i->update([
'template' => 'gallery',
]);
}
}
$item->update([
'cover' => null,
'gallery' => null,
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment