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

    I wrote my first snippet mit 2 Parameters. Now I want to write a document with many links, calling my snippet with different parameters.
    How do I do this without writing a new document for every parameter combination.

    thanx
    develix
    • Somthing like this maybe...
      [[MySnippet? &param1=`1` &param2=`3`]]
      [[MySnippet? &param1=`2` &param2=`4`]]
      [[MySnippet? &param1=`5` &param2=`6`]]
      

      Or are you meaning to say you wrote a snippet that accepts $_GET or $_POST parameters and should behave differently based on these $_REQUEST parameters (as opposed to snippet parameters) huh
        • 7200
        • 4 Posts
        I want to integrate a hyperlink in my document which links to my snippet with a special parameter set:
        somthing like this in a document:


        <A href="call my snippet with parameter 3/7">3+7</A>
        <A href="call my snippet with parameter 2/5">2+5</A>
        <A href="call my snippet with parameter 1/6">1+6</A>

        But you are right processing POST/GET Parameter in documents(?) would solve my problem. But I can not find any documentation about this.
        If I could use something like this:

        <a href="[~3~]&param1=7&param2=8">7+8</a>

        And the document with id 3 can use the POST parameter in the snippet call:

        [[MySnippet? &param1=`POST param1` &param2=`Post param2`]]

        thats what i want.
        Any links to documentation about POST/GET parameter would help me.

        thanx in advance
        develix

          • 4041
          • 788 Posts
          here is a simple example snippet which uses $_GET and switch...

          sample snippet which uses $_GET to grab param value

          sample usage - add the call below to any uncached page (id 3 for this example)
          [[do_show_message]]

          then use the following url to send the snippet some sample data to print
          http://www.your.com/index.php?id=3&param=email

          // to add a new param copy this whole block of code and rename the param
          
          $param = $_GET['param'];
          switch ($param) {
           case""; $output =""; break;
           case"name"; $output ="a Name"; break;
           case"email"; $output ="an Email Address"; break;
           case"message"; $output ="a Message"; break;
           case"nameemail"; $output ="a Name and an Email Address"; break;
           case"namemessage"; $output ="a Name and a Message"; break;
           case"emailmessage"; $output ="an Email Address and a Message"; break;
           case"nameemailmessage"; $output ="a Name, an Email Address, and a Message"; break;
          
          default: $output="";
          }
          // copy to here and add the new block before the return
          
          
          return $output;


          using the above format, add as many parameters as you want, just name the switch($param) appropriately.

          hope that helps a little anyway...
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 7200
            • 4 Posts
            I’ve tried it out and its exactly what I want to do.

            Thank you very much.
            develix