Expression Engine 2 Plugin: Empty P Stripper
I’ve got a small little Expression Engine add on., but it might be helpful if you use Pixel and Tonic’s WYGWAM to give your client’s text entry into an Expression Engine textfield a little UX love.
WYGWAM’s a good tool that I’ve used several times on sites. Clients find it an easy thing to pick up. For a recent build though, I kept noticing some strange spacing when my client was using it to create copy. There were empty P tag pairs scattered throughout the copy. I tried tweaking the preferences for CKEditor, which is the engine behind the scenes of WYGWAM, but couldn’t get these empty P tags from happening.
I ended up making a little plug in for the site to solve the problem I was having. I called it Empty P Stripper and is available on GitHub. It’s free and worth every penny. ;-)
(If you’re wondering, yes, it’s a code tweak from my SuperGeekery Tag Stripper. It was different enough that I didn’t want to add clutter to it though.)
Once you’ve got it in your /system/expressionengine/thirdparty/ folder, you can use it like this:
{exp:emptypstripper:stripMyPsPlease}
{wygwym_generated_content}
{/exp:emptypstripper:stripMyPsPlease}
It will turn something like this:
<p>This is a paragraph of text.</p> <hr> <p> </p>
And return this:
<p>This is a paragraph of text.</p> <hr>
Good luck. Let me know if it works for you.
Comments on this post.
TagStripper will strip the tags, but leave the content intact between the tags. The EmptyPStripper wipes out the content between empty P tags as well, so you don’t end up with random non-breaking spaces. As soon as you asked this question, I realized I should have probably just modified TagStripper to could nonbreaking spaces as empty content as well when it did it’s job. Live and learn, right?
I’m glad you found it helpful. It’s good to hear feedback like that!
I see. I reread your post, and noted you described the difference between this and TagStripper.
That might make sense, based on your audience: people who care about the extra “p’s” are likely interested in TagStripper also. Now I just have to learn regex to get the most out of it…
Enjoyed the recent post re: add-on development. Great stuff.
Hi Allen,
Regex is useful stuff. Check out http://tutsplus.com/course/regular-expressions-up-and-running/ It’s .not a free course, but definitely worth checking out.
Looks great. CKE can be a pain (those extra tabs!!). So, what’s the advantage of this plugin, over using your TagStripper?
Be great not to have to use a tag in your template at ALL. =)
Thanks for your work, it’s very helpful.