Remove <p> </p> tags

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 16, 2015   (RSS)

By KCMedia - April 9, 2015

Hi Guys

I have this text block

<p class="text"><?php echo ($record['content']) ?></p>

but i need to remove all the <p> </p> tags from the statement inside the content, it is using WYSIWYG and i cant change it to text block because it needs to be able to bold font and underline and so on.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz

By gkornbluth - April 9, 2015

Hi Craig,

Here's a short recipe from my CMSB Cookbook http://www.thecmsbcookbook.com that might help:

REMOVING THE <P>TAGS INSERTED BY THE TINYMCE EDITOR

CMSB uses the TinyMCE WYSIWYG editor and therefore is pretty much stuck with the concepts that it uses.
If using a textbox or a text field won’t work for you and you’re using the WYSIWYG, here’s an idea that Dave at
Interactive tools came up with in response to the issue of <p> tags.

<!-- remove leading <p>, do this _before_ displaying field value -->
<?PHP $record['yourfieldname'] = preg_replace("/^\s*<p>/i"""$record['yourfieldname'] ); ?>

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By KCMedia - April 9, 2015

Hi Jerry

yer i have tried that the issue is that it removes the first <p> tag which is great BUT because when you put a line break in WYSIWYG in the source code it dosnt put the class of the <p> tag

eg the first P tag and all P in the div should be <p class="text"> content goes in here </p> and then the next P should be the same.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz