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

    I have a really basic question but I couldn’t find it anywhere.

    when I’m creating a module and I want to insert a link somewhere like this:
    <a href="?action=dothis&ident=24">click here</a> how do I make this work in modx modules so it will actually send the data to the right scource again so I can pick it up with the $_GET function.

    thanx in advance.
      • 5727
      • 160 Posts
      I’m not sure, but I think this page could help you:

      http://modxcms.com/module-code.html
        Olivier Deland
        Montreal, Canada - Web Developer
        • 33372
        • 1,611 Posts
        Check out Susan’s tutorial on creating a module:
        http://www.sottwell.com/database-module.html

        Note especially the part where she explains how to view the ID of a module. That’s what you need to use as the base of your links within your module. Just append any other variables that you want to pass in the query string with &action=dothis&ident=24.
          "Things are not what they appear to be; nor are they otherwise." - Buddha

          "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

          Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • 27101
          • 10 Posts
          thank you both I will check them out.
            • 27101
            • 10 Posts
            Okay I checked it out, but it didn’t help me much,
            but I offcourse forgot a simple solution to it...

            I now use this in my main file
            (at the top of my php file)
            $modID=$_GET["id"];
            $a=$_GET["a"];

            (when creating a ling I start with)
            echo "<a href=\"?id=$modID&a=$a\"> click here</a>";
            this way I allways got the right module.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Yes, that will usually work. I’ve had a few times when it didn’t work, though, which is why I have instructions on how to set it as a variable when first creating the module. Then you can just use that variable wherever needed.
                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
                • 27101
                • 10 Posts
                Quote from: sottwell at Mar 23, 2007, 05:20 AM

                Yes, that will usually work. I’ve had a few times when it didn’t work, though, which is why I have instructions on how to set it as a variable when first creating the module. Then you can just use that variable wherever needed.

                How do I call on that variable,
                just using the $_GET function?
                  • 5727
                  • 160 Posts
                  I believe that the variable is simply, instantly accessible by its name.

                  So, if you create a parameter named ’modId’, you can access it by using $modId. Use global $modId inside functions.
                    Olivier Deland
                    Montreal, Canada - Web Developer
                    • 33372
                    • 1,611 Posts
                    Actually, you should always refer to variables passed in the query string as they exist in the $_GET array (this makes it clear where the value is coming from; even if some later change to MODx alters the value of $id in that context $_GET[’id’] will still be what you expect). It’s fine to use $modID=$_GET["id"]; at the top of your script as well. I usually do that if I’m going to change the value but not otherwise.
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Zap, we’re referring to setting the $modId in the module configuration. Then it’s always available.
                        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