We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20751
    • 122 Posts
    I’m trying to add the current page url to a link via a snippet.

    Is there a way of getting the whole url of a page using the modx api. Something like this is what I’m after:

    snippet called geturl for example:

    $url = $modx>somethingHere;
    return $url;


    Code:

    <a href="somepage.html?url=[[geturl]]">Link Text</a>


    Result I want:

    <a href="somepage.html?url=http://www.mysite.com/parent/child.html">Link Text</a>


    Any pointers on how I might achieve the above?

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      $modx->makeURL($modx->documentIdentifier)

      Or, in the HTML itself, [~[*id*]~] - no need for a snippet.
        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
        • 20751
        • 122 Posts
        hehe . . . boy do i feel dumb! Didn’t think of that! Thank you!

        grin