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

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