We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32982
    • 674 Posts
    im going cracy
    i need to pass to a snippet a value from the template in couldent do
    y use [[snippet?myvariablename=myvariablevalue]]
    i dont know whath i need to take the value to the snippet
    whats need
    is posibol to pass multiples values lika a array...
    thaks
      Jabiertxof (formerly XYZVISUAL)
      My bussines: http://marker.es
      https://www.youtube.com/user/jabiertxof/videos
      • 18397
      • 3,250 Posts
      MARKSVIRTUALDESK Reply #2, 21 years ago
      You can do this

      [[snippet?var1=cheese&var2=cheesier&var3=cheesiest]]
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        You could "fake" an array by passing an argument like this: [[MySnippet?arrayArg=`arg1-arg2-arg3-arg4`]], and then in the snippet load an array from the argument with

        if(isset($arrayArg)) {
        $arrayArgs = explode("-", $arrayArg);
        }

        I’m not sure if there’s any limit to the length of an argument

        Take a look at some other snippets to see how they handle their arguments, most of the menu snippets have several possible argument that they process, usually near the top of the code.

        Basically, it’s just something like

        $argA = isset($arg) ? $arg : "default";
          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
          • 32982
          • 674 Posts
          thanks very much
          i continue working in my snippet
            Jabiertxof (formerly XYZVISUAL)
            My bussines: http://marker.es
            https://www.youtube.com/user/jabiertxof/videos