We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40747
    • 18 Posts
    I want to use GET method in my snippet. When I click href with address, eg. example.com/index.php?id=3&color=1 and I use var_dump to see $_GET, there are: array(2) { ["id"]=> string(1) "3" ["color"]=> string(1) "0" }

    Is there some function to read GET information in MODx, or what?
      • 36996
      • 211 Posts
      You can use it in a snippet and do what you want with it just like any other php script:
      if(isset($_GET['color']){
          
          $color = $_GET['color']
      // Do your stuff...
      }
      
        • 40747
        • 18 Posts
        Yes, but it doesn't work good. Once again: I have index.php?id=3&color=1 href, and firstly var_dump displays color=1, but when I change address to eg. index.php?id=3&color=8&size=4 it won't display new values (there were still color=1) until I'll clear cache in MODx...
          • 38705
          • 101 Posts
          How about calling the snippet uncached?

          instead of
           [[MySnippet]] 

          use
           [[!MySnippet]] 

          just add the exclamation.

          PS also always sanitize your input!
            Addict since 2012....
            • 40747
            • 18 Posts
            Thank U laugh It works laugh