We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45063
    • 40 Posts
    I'm trying to insert output modifier [[+bodytext:replace=`One==Two`]] in context settings, which replaces word One with word Two in whole document body. Calling setting in Head like this: [[++replacer]] but nothing happens. The goal is replace the words across all context and replace to another word in different context. Does modifiers work this way? And for come reason, in my case, modifiers doesn't work even when I am placing [[+bodytext:replace=`One==Two`]] straight in the page body.
    Thanks for you future help.

    ADD: Modifiers are already working outside of context settings. But still, I don't know how to make replacement of some string in the whole document body. [ed. note: roman.khazizov last edited this post 12 years, 11 months ago.]
      • 3749
      • 24,544 Posts
      I'm not completely clear on what you're trying to do, but there is no bodytext placeholder unless you've created one.

      If the text you're trying to change is all in the content field of the resource, putting this in your Template where the content tag is might work:

      [[*content:replace=`One==Two`]]


      If you want that to be context-sensitive, you could use a Context Setting containing `One===Two` and use this for the content tag:

      [[*content:replace=[[++ContextSettingName]]]]


      If some words you need to replace are not in the 'content' field, you could create a plugin with custom code to do the replacements.

      Another way to go would be to make all the words that need replacing into either language tags, placeholder tags, or Setting tags. Using Setting tags would be the most straightforward.

      For example, use a Setting tag like this:

      [[!++someWord]]


      And a Context Setting with a key of someWord and a value that's what you want to replace the tag with.


        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 45063
        • 40 Posts
        Thanks a lot, got it working for now. Now, the other problem described here: https://forums.modx.com/thread/86593/can-039-t-view-resource-in-non-default-context