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
    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 Aug 27 '13 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 Aug 28 '13 at 16:40
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.
  • 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. – Steve Holland Aug 28 '13 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 Aug 28 '13 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, privacy policy and cookie policy

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