Bike Posted May 26, 2021 Share Posted May 26, 2021 Hi everyone, currently I am transferring data from an old database to PW using the API. Textarea in old DB be like: <p>...</p><div dir="somecrappytags">i don't want that</div> Textarea in new DB, of course is exactly the same BUT: when I open and save that textarea in admin, CKEditor replaces all the divs with <p>, and that is what I do want! How can I achieve that formatting CKEditor does within the API? Like simulating open up and save the data in the admin to get rid of all those stupid tags and just keep the paragraphs? Is it sanitizer stuff?! Does anyone understand? ? Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 26, 2021 Share Posted May 26, 2021 You might want to give $sanitizer->purify() a try. 1 Link to comment Share on other sites More sharing options...
Bike Posted May 27, 2021 Author Share Posted May 27, 2021 Thanks @wbmnfktr, seems to be the right track though I cannot get it working properly. Code is like: $options = array( // markup tags that are allowed. Example: "<br/><strong>" 'allowableTags' => '<p>', ); $p->text = $sanitizer->purify($data["comment"], $options); Other tags still appearing. Also I tried to use $markupHTMLPurifier as there are many more options such as br to p, remove emtpy p etc. which doesn't seem to be available in $sanitizer. But the function is unknown. Any clue? Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 27, 2021 Share Posted May 27, 2021 No clue right now. I have to test it here and will keep you updated. 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