We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    I have have URLS that contain an ampersand character that I need to be able to copy and paste into my template variable. The output is used as content in an XML feed, so I need to escape the ampersand and replace with &

    I could do this manually before I paste in the url, but if there is a way to do this with an output modifier, that would make life easier and eliminate possibility of typos.

    esc,escape seems like the logical choice. Can it be written along with the template variable call in my chunk, or do I need to write a snippet first, and put the snippet call in my chunk.

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      There is a replace output modifier https://rtfm.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/input-and-output-filters-%28output-modifiers%29#InputandOutputFilters%28OutputModifiers%29-Stringoutputmodifiers
      [[+pagetitle:replace=`Mr.==Mrs.`]] 
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 19872
        • 1,078 Posts
        Thank you for responding Susan. I very much appreciate it. [ed. note: mmcgee last edited this post 10 years, 7 months ago.]
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Did that do what you wanted?
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 19872
            • 1,078 Posts
            Quote from: sottwell at Feb 28, 2016, 12:03 AM
            Did that do what you wanted?

            Not sure yet. Kind of stumped on what to put where. Trying to remember the process and what to put where.:) Once I get some things in place, I'll post back — with good news I hope.:)



              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I presume your TV is used in generating the XML?
              (spaces used because the actual HTML entity will be parsed by the forum software)
              [[*tv:replace=`&==& amp ;`]]

              Or maybe what you need is
              [[*tv:htmlentities]]
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 19872
                • 1,078 Posts
                I put the following inside the chunk. Works great.

                <ContactUrl>[[+tv.47-ContactUrl:replace=`&==&`]]</ContactUrl>
                  • 19872
                  • 1,078 Posts
                  Ha! — the only way I know how to get my TVs to display in a specific order in the manager is to number them. (i.e. 47-ContactUrl)
                  Kind of like building a web form, go in increments of odd or even, or even increments of 5 or 10 just in case I need to come back an stick a new one in somewhere, I don't have to renamge the remainder of TVs.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    I believe you can use the "Sort Order" field when creating the TV. It's on the General Information tab, on the right, just under the Category drop-down.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 19872
                      • 1,078 Posts
                      I think I have tried that before. I went the route I did because I can see the list in the tree, assign the number and visually see it change position in the tree. Whereas, if I remember correctly — the sort order number cannot be seen unless you have that TV open. If I forget what the previous number I entered was—I end up messing up the order or spending more time revising it.