Convert kirbytext to kirbytext block


I make a conversion from wordpress (old post) to kirby (old and new post). My old text filed are in kt(), new post are in blocks. I use this trick :

if(is_array(json_decode($page->text()))): /*  and more code */

It’s OK, but if I edit an old post, I loose my text paragraph.

How to batch convert text field kt post.txt to blocks ?

Is it possible to update and save in .txt a field value from

Text : lorem ipsum


Text: [{"content":{"text":"<p>lorem ipsum<\/p>","dropcap":"false"},"id":"d1f70f55-4c8e-4676-ae91-6efdf362ff0e","isHidden":false,"type":"text"}]

I guess these Kirbytext fields contain more than just text? Images etc.


I found how to make an hook with a plugin…
So I need to know how to convert kt to block… maybe on page before edit.

  1. grab the text field
  2. convert to array and object (how get an id ?)
  3. update the text field

Maybe Markdown is possible…
Text: [{"content":{"text":"<p>lorem ipsum<\/p>","dropcap":"false"},"id":"d1f70f55-4c8e-4676-ae91-6efdf362ff0e","isHidden":false,"type":"markdown"}]

I recently wrote this quicktip, maybe it helps: Quicktip: Add blocks to a blocks field programmatically | Kirby

1 Like

Yes, I found this few minutes ago :slight_smile: