We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12958
    • 9 Posts
    Hello,

    seems I don’t understand how to use output filters with placeholders huh.
    (Whereas output filters with TVs work well)

    For example: the placeholder "title" is created in a snippet and processed by a chunk like this:

    $params['title'] =  "Lorem Ipsum";
    $output.=$modx->parseChunk('forumTpl', $params);
    


    The output via chunk works well with [[+title]],
    but doesn’t work with output filter, e.g. [[+title:lcase]] (outputs nothing!).

    (MODx Revolution 2.0.6-pl (traditional))

    Thank you for any helpful hints
      • 3749
      • 24,544 Posts
      Try making the tag in the chunk uncached.

      [[!+title:lcase]]


      and in your snippet, just set the title placeholder and get the chunk without parsing it:

      $modx->setPlaceholder('title',$params['title']);
      return $modx->getChunk('forumTpl');


      If you’ve got a bunch of them, you could use $modx->toPlaceholders($params) or $modx->setPlaceholders($params).

      Be sure that either the page or the snippet is unached as well.
        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
        • 12958
        • 9 Posts
        Thank you very much for your reply, outputfilters with placeholders work very well now!

        Just to be sure: Is this the right syntax now?

        $params['name'] = "John";
        $params['fehler'] = "Fehler";
        
        $modx->setPlaceholders($params);
        
        return $modx->getChunk('forumTpl');





          • 3749
          • 24,544 Posts
          If the placeholders are in the chunk, you can skip the setPlaceholders() part and just do this:

          return $modx->getChunk('forumTpl' , $params);


          getChunk() will do the replacement for you.

          You only need to explicitly set them if they are in other places on the page.

          You can also do this to set up the array:

          $params = array(
                     'first_name'=>'John',
                     'last_name'=>'Doe',
          );
            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