We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18174
    • 116 Posts
    a bug or a feature?
    If my custom outputfilter returns a null string
    return '';
    the source value seems to be left untouched. This is not logical.
    if my custom outputfilter returns a blank character
    return ' ';
    the source value is replaced by the blank character.
    If this is a feature this behaviour should be noticed in the rtfm manual.
    regards
    manu
      • 4172
      • 5,888 Posts
      in modoutputfilter.class.php there is:

      $tmp = $this->modx->runSnippet($m_cmd, $params);
      if ($tmp!='') $output = $tmp;
      


      so, if you return an emtpy string by your output-filter-snippet, the output isn't touched
      But I can't say what's the reason for this line.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 18174
        • 116 Posts
        That's the point.
        For me it is or was a bit confusing.
        IMO if I want to leave the source value untouched I would
        return $input;

        There is probabely a reason for this behaviour. If this would have been noticed in the manual, it would have saved time of troubleshooting on developing more complex outputfilters.
          • 3749
          • 24,544 Posts
          I added a note about this in the docs.
            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
            • 37059
            • 368 Posts
            One possible kludge of a solution: Set a dummy value and use the :replace output filter to suppress it.

            [[+myvalue:doSomething:replace=`dummyvalue==`]]
            
              Jason
              • 18174
              • 116 Posts
              I can live with the outcome and know possible work arounds. But as I mentioned in #1 it's just not logical to me.
              If I want to leave the source value untouched I would
              return $input;
              or
              return;
              But for me a nullstring is a value and therefore
              return '';
              should return a nullstring.
                • 37059
                • 368 Posts
                Yeah, +1 on that. I don't see why an output filter should work differently from a standalone snippet or anything else: return null means return null.
                  Jason