I'm looking to dynamically replace the ℠ glyph with <sup>SM</sup> in all rich text fields, since that glyph doesn't exist in the font we're using. I'd like to avoid having to call the |replace filter on every field in every template, and I can't seem to get the customAsciiCharMappings general config setting to work either (I'm not sure if I really understand what it does). Does Craft have something like a global replace function/filter?

1 Answer 1


customAsciiCharMappings won't help you here.

There is the "Find and Replace" tool available to admins (Settings->Tools) in the Control Panel, but its' a one-off thing and searches/replaces against all textual field types (Plain Text, Rich Text, etc. both inside and outside of Matrix fields).

Honestly, probably just create a small Twig macro that wraps |replace and use that wherever you're outputting Rich Text fields on the site.

  • Awesome, thanks! I'm not sure the macro would be more convenient than manually wrapping them all in |replace but that looks like the best way.
    – jtenclay
    Commented Sep 15, 2017 at 17:34

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.