Remove <p> </p> tags

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

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

By gregThomas - April 16, 2015

Hey Craig,

I just want to confirm what you're trying to achieve. Do you want to remove all of the opening / closing p tags from a bock of text, and replace them with line breaks? Or do you want to add the class text to each p tag in the block?

I'm wondering if there is a simpler way to do this using CSS instead of doing a find and replace with PHP. Perhaps wrapping the content with a div instead of a p tag, then styling the p tags inside the div instead would work?

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com