I am allowing users to type a 'review' and that info is being added into my db table. I've noticed that for text, it adds <p> and </p> around the text.
Is there a way to have it NOT add those tags? Its causing a problem when I want to display the information on a different page..
Is there a way to have it NOT add those tags? Its causing a problem when I want to display the information on a different page..
Re: Removal of <p> and </p> tags around data ??
Re: Removal of <p> and </p> tags around data ??
(this will remove only <p> tags surroundig the whole text *.)
(this will replace all <p> tags into <div>)
* - this solution is valid only if there is one <p> tag surrounding the whole text, like for example "<p>text</p>".
For more complex strings like "<p>text1</p><p>text2</p>", it will return "text1</p><p>text2", so additional check is required.
So the real solution would be to do a search for </p> tags and do a replacement only if only one closing </p> tag is found.
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Removal of <p> and </p> tags around data ??
The data that is in #ReviewDisplay.Rev_Comments# shows as:
<p>This is just a test</p> <p>Let me know how it works</p>
When I run the code with the regex, I still get:
<p>This is just a test</p> <p>Let me know how it works</p>
???
Re: Removal of <p> and </p> tags around data ??
In PHP, first char defines closing tag for regular expression, thus /<p.*?>/ is equal to <p.*?> in ColdFusion.
Will output
This is just a test</p> <p>Let me know how it works
As you see, you must add additional checks here (whether <p> tags exists inside text). If, after replacing starting and ending <p> tag with the code above, there are still some <p> tags, simply use
the original text.
Second example (replace all <p> tags with <div>, Coldfusion version):
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+