We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46580
    • 167 Posts
    Is there a simple way to use programmatically Output Modifiers (especially for search & replace characters/strings)?
    http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/input-and-output-filters-%28output-modifiers%29
      MODX lover
      -
      Développeur MODX / Webdesign / Solutions web
      • 38850
      • 110 Posts
      Which part needs to be programmatic?

      If you replacement string is programmatic, just use a snippet or whatever it is where you are getting the string from:

      [[*SomeValue:replace=`Mr.==[[SnippetReplacement]]`]]


      MODX processes all tags "inward to outword" so it shouldn't be an issue.
      The entire inside of "replace=" could be a snippet to dynamically create the replacements. In fact, you can create an entire snippet and use it as the output filter:

      [[*theValue:mySnippet]]


      Then the "mySnippet" can process the text however it wants and return the result.
        • 32699 ☆ A M B ☆
        • 427 Posts
        To clarify, the output filters are processed from Left to Right (also known as the order they are encountered by the parser). As each one is processed the Value is changed according to the filter.

        For example:
        <meta property="og:updated_time" content="[[*editedon:empty=`[[*publishedon]]`:strtotime:date=`%FT%X-0500`]]" />


        The content="" will first have a value of the editedon value of the resource, if it is found. If not the publishedon date is used.

        Next the date value which was used if formatted to comply with the format shown.

        You can have multiple filters of the same type if you so desire.

        <meta name="keywords" content="[[$tags:striptags:strip:replace=` ==,`:replace=`-==,`:default=`none`]]" />


        This removes the html tags, strips the white space, converts the remaining spaces to commas and then replaces hyphens with commas.
          Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

          Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
          • 46580
          • 167 Posts
          In fact I'd like to use a TV with @CHUNK (input) to populate a select list, with output modifier.

          something like @CHUNK thechunk:replace...

          @CHUNK binding works fine but I don't knows if I can add output modifiers, the I'm thinking to use @EVAL and a snippet...

            MODX lover
            -
            Développeur MODX / Webdesign / Solutions web
            • 32699 ☆ A M B ☆
            • 427 Posts
            Quote from: johnxx at Mar 09, 2015, 03:14 PM


            something like @CHUNK thechunk:replace...


            That is what my second example does. EVAL is heavy and typically not recommended.

            Just put the filter on whatever element is being sent to the Resource.
              Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

              Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com