We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26439
    • 104 Posts
    I’d be interested to hear what methods people might use to achieve this.

    Basically what I want to do is, ( in good old fashioned php ) this....

    Have a link to another page with as in..

    <a href="page2.php&name=me>link</a>
    


    then on page2.php

    echo "hello ".$name;
    


    Obviously I want to do more than that, but that is the general principle, and if possible ( probably pushing it ) while using friendly urls.

    ( a form with a hidden field might be an option? )

    TIA
      • 11975
      • 2,542 Posts
      hi,

      your syntax is wrong

      <a href="page2.php?name=me>link</a>


      snippet code:
      $mess = "hello ".$_GET['name'];
      return $mess;
      


      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 26439
        • 104 Posts
        My syntax is usually wrong on first attempt. undecided

        Ok, I couldn’t seem to pass a variable once I turned on Friendly Url’s, what would be the procedure there?

        ( and thanks )
        • If friendly URLs are turned on, you need to use ?. If they are not, you need to use &.

          This is because without friendly URLs, you want index.php?id=xx&mykey=myvalue. With friendly URLs you want mypage.html?mykey=myvalue.

          In a snippet you can have a check for the status of friendly URLs and use a variable that will resolve to ? or & in generating the URL.

            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
            • 19726
            • 239 Posts
            When you want to generate a link from a snippet or plugin just use the makeUrl API call. The API call will take all the friendly URL settings into account automatically.

            Example:
            $modx->makeUrl(id_of_page_to_link_to, ’’, ’name=me&something=different’);