Jump to content

Change textarea formatting as CKEditor would do through API


Bike
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...