We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8109
    • 128 Posts
    I have written my first funcitoning snippit. I’m so happy. It is very simple: The snippit takes one or two parameters and parses a chunk with placeholders for those paprameters. The Chunk is a MaxiGallery snippit call. In this way I can take a legnthy snippit call that I use all over the place and reduce it down to a very short call. The code looks like this:

       $params['mgPicID']=$mgPicID;
       $chunk=$modx->parseChunk('mg1PicCall', $params, '[+', '+]');
       return $chunk;


    My next hurdle is that the snippit in the chunk accepts templates, stored in chunks and called by chunk name. I would like to insert placeholders in the template chunks and use my snippit to fill those in, but I can’t figure out how. I’ve looked at the setPlaceholder API function, but I didn’t get anywhere with that. Can someone point me in the right direction.
      Revo 2.0.8-pl
      • 3749
      • 24,544 Posts
      Usually, we call them tpl chunks, not templates (which are something else). One common method is to use $modx->getChunk(’chunk_name’) to retrieve them and str_replace to fill in the "placeholders."

      BTW, it’s snippets, not snippits. wink
        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
        • 8109
        • 128 Posts
        Great, I’ll give that a try. Hard to imagine that the snippit would then call my altered version of the chunk rather than a fresh, unaltered one.
          Revo 2.0.8-pl