3

What's the best way to have an unformatted textarea field (meaning no <p> or <br> tags), but still allow the client to make text bold, italic, or add a link?

I often have to put content into a specific element (<p class="summary">, for example), so it can't be wrapped in its own <p> tags. And often for styling purposes the content can't have line breaks. But the content can still have bold or italic text or contain a link. Example:

This is an example of some summary text. Text can be bold, or it can be emphasized, and it can even contain a link because these are all inline changes that don't affect layout.

Is there any client-friendly way (read: no html tags) to accomplish this?

2
  • 2
    Could you: Create a very minimal Wygwam config, with just Bold, Italics, and Link options. Then in your template, wrap the Wygwam tag with something like Low Replace to remove all <p>, </p>, <br>, and <br />
    – Dylan T
    Commented Aug 27, 2013 at 19:16
  • @Dylan That's certainly an option, I just wish I didn't have to add the extra overhead of a plugin.
    – kmgdev
    Commented Aug 28, 2013 at 16:40

2 Answers 2

3

Couple of suggestions:

  • have you looked into using Textile or Markdown for your textarea?
  • use a div.summary instead of a p
  • CE String has methods to strip out tags from html, check remove_tags or remove_tags_except (I use this a lot personally - lots of other useful methods too in this plugin)
  • Wygwam has a text-only mode that can be useful.
2
  • 1
    I would second what erwinheiser has suggested. EllisLab have just added Markdown parsing to the new 2.7 release and that's sounds like a good fit for what you need. Commented Aug 28, 2013 at 8:51
  • @Steve_Holland ORLY? I didn't know they support Markdown now. That sounds pretty good. Still not as client-friendly as a WYSIWYG, but better than raw HTML.
    – kmgdev
    Commented Aug 28, 2013 at 16:41
1

You could use the built-in html formatting buttons in EE, which can be enabled on a Textarea field. This would meet your requirement of no br or p tags without the need of a plugin to strip them out.

When the user clicks a formatting button the correct html is applied automatically, but it does leave the tags exposed (not a wysiwyg).

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.