Reputation: 2546
Hi i am using tinyMCE editor and having a problem retrieving the content from database.
Whenever i type this
Lorem ipsum dolor sit amet dolor amet sit dolor ipsum.
[youtube_video_here]
it successfully saved into database. However, when i tried to display it from database instead of printing the code below
<iframe ....the rest of the code
it prints
>iframe ...the rest of the code <>/iframe>
Oddly enough it prints other HTML tags such as
<br/> or <p>
properly.
I am using PHP in CodeIgniter to retrieve the content.
Does anyone have any idea?
Upvotes: 1
Views: 1094
Reputation: 324
There are several ways to achieve this. Not all will work for you, so you'll have to try until you find the correct solutions. Best way is to store properly the content in your database.
Variant 1. TinyMCE config. Add this line
extended_valid_elements: "iframe[src|width|height|name|align]"
More info here: extended_valid_elements
Variant 2. Decode this params before saving to the database. With PHP you'll do this:
$content = html_entity_decode($content);
Then save to your database.
Variant 3. Quick&dirty. Maybe I should start with this :)
$content = str_replace('<iframe', '<iframe', $content);
$content= str_replace('></iframe>', '></iframe>', $content);
$content= str_replace('></iframe>', '></iframe>', $content);
Let me know if I can be of further help.
Upvotes: 1