views:

378

answers:

2

when i display ckeditor text the html tags are also displayed. how can a i show only the text? i'm getting this:

<p> &nbsp;</p> <ul style="list-style-type: none; list-style-image: none; list-style-position: outside;"> <li> Nurzahan Road,Dhaka</li> <li> West of Tajmahal Road</li> <li> Phone: 9110614</li> </ul>

i want to show only this:

* Nurzahan Road,Dhaka
* West of Tajmahal Road
* Phone: 9110614
+1  A: 

You have probably a htmlentities() or htmlspecialchars() somewhere in the code that displays the HTML code. If you put in the HTML as you quoted it into a HTML page, it should turn up as desired.

Pekka
hi pekka,this is the line used to print <? echo $data[contact];?>
Where does that variable come from? A database?
Pekka
You could try `echo html_entity_decode($data["contact"]);` for a quick fix but you should really clarify where your data comes from, so somebody can recommend a clean solution.
Pekka
thanks a lot man...echo html_entity_decode($data["contact"]); this works fine. data is coming from db.
You're welcome, but it would be really better to find out why the code goes into the database entitie()d, it shouldn't do that in the first place.
Pekka
is there any other way to save marked up text into databse?
We can't answer that because we don't know what code you use to save it to the database. I think it would merit another question of its own, though.
Pekka
A: 

question not clear to me, so here are my solutions:

coming from database/post:
- you are having an escaped string: do html_entity_decode() for getting real html - you are having a not escaped string: do htmlentities() for getting an escaped string

coming from ckEditor:
- you want to get plain text: use getText() for the domElement - you want to get html: use getData() for the editor

there is always some threat for injection, so be careful to not allow eg. script-tags

Andreas Niedermair
need the "marked up" text
htmlentities() is the reason why he is getting the text as he describes.
Pekka
thanks...working fine