joe_g Posted May 15, 2017 Share Posted May 15, 2017 Hi there, I've got an old site with tons of content written in markdown. Wysiwyg editing has matured a bit since 2010 and the client would like to change to ckedit. The question is what to do with all the old markdown, can it be converted somehow? Did anyone do this? Any tips? – thanks! Link to comment Share on other sites More sharing options...
Zeka Posted May 15, 2017 Share Posted May 15, 2017 Hi @joe_g Maybe you can loop over all your page and just save output of your markdown field to the newly created ckeditor field $yourpages = $pages->find("template=some"); foreach($yourpages as $p) { $p->ckeditorfiedl = $p->oldfield $p->save(); } 3 Link to comment Share on other sites More sharing options...
joe_g Posted May 15, 2017 Author Share Posted May 15, 2017 right, thank you. Pretty simple Link to comment Share on other sites More sharing options...
Robin S Posted May 17, 2017 Share Posted May 17, 2017 @Zeka's suggestion is the right direction, but a couple of extra things are needed: $your_pages = $pages->find("template=some_template"); foreach($your_pages as $p) { // Output formatting must be off before manipulating and saving the page $p->of(false); // You need to get the formatted value of the markdown field // i.e. with the textformatter applied $p->ckeditor_field = $p->getFormatted('markdown_field'); $p->save(); } Or a shorter way that takes care of the output formatting using setAndSave(): $your_pages = $pages->find("template=some_template"); foreach($your_pages as $p) { // Normally you wouldn't want to save a formatted value with setAndSave() // but in this case we do $p->setAndSave('ckeditor_field', $p->markdown_field); } 2 Link to comment Share on other sites More sharing options...
Zeka Posted May 17, 2017 Share Posted May 17, 2017 @Robin S Thank you for your addition. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now