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.
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.
thank you both I will check them out.
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.
-
☆ 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.
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.
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.
-
☆ A M B ☆
- 24,524 Posts
Zap, we’re referring to setting the $modId in the module configuration. Then it’s always available.