We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17379
    • 26 Posts
    How can I send to snippet parameter with char "=" inside? Its about URL - in it there is often = in :/ I need to send it to snippet. I try some binding (@CODE) but this show me only my link with "@CODE " before :|
    Thanks for help
      • 22303 MODX Staff
      • 10,725 Posts
      In Evo, you’ll need to encode any ?, &, or = characters you want to pass through snippet parameters, and then decode them in the snippet. See FeedX and other snippets that accept URL parameters for examples of this.

      In Revo, these characters are acceptable within the backticks which delimit the parameter values.
        • 17379
        • 26 Posts
        Ok I know how to encode the url in snippet but how can i decode it first?
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: loganix at Jun 29, 2009, 04:55 PM

          Ok I know how to encode the url in snippet but how can i decode it first?
          That completely depends on how you encode those characters. I did not mean urlencode()/urldecode() BTW, I just mean to use alternative strings to represent those characters and then transform them in your snippet code. IOW, I might "encode" the equal sign as |eq| and then in my snippet I might do
          $url = str_replace('|eq|', '=', $url);
          where $url is the snippet parameter containing the URL.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You can also use a wrapper snippet to call the original.
            $modx->runSnippet('snippetName', array('param1'=>'value1', param2=>'value2);

            by putting the parameters in the array you can have whatever you want.

            Another solution is to use a config file. The only parameter in the snippet is &config=`filename` and the first line of your snippet code would include that file
            include 'assets/snippets/mysnippet/'.$filename.'.php';


            The config file itself would be a list of standard PHP variable definitions
            <?php
            // parameter list for my snippeet
            $param1 = 'value1',
            $param2 = 'value2';
            ?>
              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