ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Converting special characters to HTML entities when "Default Text Formatting for This Field" is None

July 24, 2011 1:36pm

Subscribe [3]
  • #1 / Jul 24, 2011 1:36pm

    northk

    51 posts

    Greetings all,

    When “Default Text Formatting for This Field” for a channel field is set to “None”, special characters will not be converted to their respective HTML entities. This seems to be OK for ampersands and quotes since I’m using UTF-8 character encoding for my pages.

    However, it does not work for other characters such as ‘<’ and ‘>’. The result is when these are entered into a custom field with text formatting set to None, invalid HTML will be generated. I’m wondering if there is a way in EE to turn on conversion of characters to their HTML entities when using “None” for text formatting.

    Otherwise, I’m looking for any suggestions on the best way to handle this. The goal is to make it OK for clients to input whatever they want into a simple text field that will be used for titles of sections on a page. It makes sense for these titles to be formatted with “None” since they will be simply wrapped in an <h3></h3>.

    I’m using EE v2.2.1 - Build: date 20110630.

    Thanks,

    -NorthK

  • #2 / Jul 25, 2011 12:15pm

    Sue Crocker

    26054 posts

    Hi, NorthK.

    Possibly one of the available Find and Replace plugins? Untested, but it’s the first thing that comes to mind.

  • #3 / Jul 25, 2011 1:15pm

    northk

    51 posts

    Hi Sue,

    It appears that there are a couple of plug-ins that handle text conversion to HTML entities. However, I wanted to first make sure that there isn’t a built-in way to do this in EE—can you confirm that please?

    It seems like this would be a very common use case—I think it would be desirable any time a design includes something like

    <h2>{data-item-here}</h2>

    where you would use text formatting of type “None” so it doesn’t get paragraph tags stuck in.

    For anyone reading this later, the plug-ins I found are:
    http://devot-ee.com/add-ons/eencode/ (this one appears to be written for EE2.x)
    http://devot-ee.com/add-ons/xml-encode/ (written by Rick Ellis himself, but it’s unclear if it works on EE2.x).

    Thanks,
    -NorthK

  • #4 / Jul 26, 2011 4:41pm

    Brandon Jones

    5500 posts

    Hi NorthK,

    A plugin would be appropriate in this case, though I think that’d make a good feature request. Thanks for the feedback!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases