tonymx227
tonymx227

Reputation: 5451

Insert HTML codes in CKEditor textarea

I would like to know if there is a plugin in order to insert HTML codes in a CKEditor textarea?

I tried to install the PBCKCode plugin but it doens't work because the HTML is executed in my textarea.

Anthony

EDIT1 ----- INSERTPRE Plugin -------

Query when I add the post :

    INSERT INTO `Posts` (`slug`,`title`,`thumbnail`,`content`,`tags`,`state`,`click`,`createdAt`,`updatedAt`,`id`) VALUES ('dsq','dsq','http://4.bp.blogspot.com/-knCgLUMOkJc/TeMY2jkmACI/AAAAAAAAAV0/VByHmoMa2N8/s1600/first+blog+posting.jpg','<pre class="prettyprint">\r\n&lt;div&gt;toto&lt;/div&gt;</pre>\r\n\r\n<p>dqsdqs</p>\r\n','toto','0',0,'2013-04-30 12:15:46','2013-04-30 12:15:46',NULL);

The result in my textarea when I try to edit the post :

    <pre class="prettyprint">

    &nbsp;</pre>

    <div>toto</div>

    <p>dqsdqs</p>

As you can see the "div" have changed of place.

EDIT2 ----- Escape HTML -------

Screenshot : http://grab.by/m8bs

As you can see it works in a P tag (just above the slug) but it doesn't work in my textarea. I think CKEditor encode my content but I don't know when and why... In my database everything is ok, I have the codes into the PRE tag.

Upvotes: 0

Views: 10885

Answers (3)

Abo Tasnim
Abo Tasnim

Reputation: 1

Okay Try This

for added Post

addslashes($_POST['post_from_textarea']);

to Edit

stripslashes($yourvairablegetRowsQuery)

Upvotes: 0

Reinmar
Reinmar

Reputation: 22023

Check these two plugins:

We use the first one on http://ckeditor.com/forum and it works very well.

Update: That's because you're not encoding HTML before you pass it to textarea. Use htmlspecialchars (or other similar function if you're not using PHP) to do that.

Update2: You are doing something wrong, but I don't know on what stage. The output data (editor.getData()) from the editor with one <pre> element is:

<pre class="prettyprint">&lt;div&gt;</pre>

See that <pre> is not encoded, but <div> inside it is. Your examples show me that you "flattened" that structure - you have encoded both things equally when it should be:

&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;div&amp;gt;&lt;/pre&gt;

Note: &amp;lt; is an encoded &lt;.

Upvotes: 3

Padmanathan J
Padmanathan J

Reputation: 4620

You can use source menu in ck editor header to add your html

Use this tutorial demo link

Upvotes: 0

Related Questions