Janitor to copy layout fields


I used the Janitor Plugin to show a button in the panel to copy the contents of one translation to the other. This works perfectly for pages that have a blocks field for their content.
But for layout fields, this does not work. All fields’ names are the same, so that cannot be the reason.

Does anyone know what the issue might be?

Here is my code:

'bnomei.janitor.jobs' => [
    'copy' => function (Kirby\Cms\Page $page = null, string $data = null) {
        if ($page === null) {
          $page = site()->index(true)->findByID($data); 
        $languages = kirby()->languages();
        $language = $languages->not(kirby()->language())->first()->code();
        $content = $page->text();
        $newPage = $page->update(['text' => $content], $language);
        return [
            'status' => 200,
            'label' => 'Kopiert.',

Thank you in advance!

I found the solution myself, for anyone interested.

Appending ->toString() to ->text() did it.

1 Like