Convert Textarea to Writer + Update existing Content

I have an existing Website where I would like to convert a Textarea field into a Writer field.
Of course this is not a big deal for new content, but is there a way to convert all the existing content from many Pages?

At the moment I would probably just create a new Template for all the newly created pages and let the existing Pages still use the Textarea field. But maybe there is a simple solution to convert the content?

Thank you for any inputs!

Do you want to convert to blocks or to the writer field?

What sort of KirbyTags are you using in your textarea fields? Keep in mind that the writer field is not a replacement for the textarea field. It only supports a limited set of nodes.

Hi there :slight_smile:

I’m following up on that. I have a client website with tons of content. Recently we updated to K4 and while that we switched from the Markdown Field for Kirby to the writer field, as it has the just the capabilities we need and is way simpler for the editors.

Specifically we used the italic, bold, strikethrough, external urls, pages and superscript.

Mainly it’s not a problem, as the old pages still display correctly in the frontend. (I call ->kt() on all the fields), but once you edit a page originally written with the markdown field all the linebreaks disappear.

As it’s really a lot of content (also within blocks and multilang :see_no_evil: ) I don’t know if it’s humanly possible to convert this by hand.

Do you think there’s any way to convert this with a script? At least the linebreaks would definitely help a lot.

Thank you already and have a sweet weekend! :slight_smile:

I think as long as your Markdown fields don’t contain anything that is not supported by the writer field, you can just loop through the pages, get the value of the markdown fields, convert to Kirbytext and save the rendered Html back to the field. Multilang is not a problem.

It will get more complex when your Markdown fields are nested within a blocks or layout fields. But not impossible.

But I asked the TO above, what kind of Kirbytags were used. If you have complex Kirbtags they might not be compatible with nodes supported in a writer field.

Thank you for your reply! :slight_smile: I think the nodes I used should be compatible, but yeah a lot of content is nested in blocks. As the budget for this project already reached it’s end, I’ll most probably not go further with that.

Out of curiosity, my first thoughts were to use a kind of similar approach as the content file cleanup script. Or would a page hook be the better way to go?