How to Print the Current Page URL in MODX
You can echo the current MODX resource's full page URL without the use of a snippet call.
You can echo the current MODX resource's full page URL without the use of a snippet call.
Typing this:
[[~[[*id]]? &scheme=`full`]]
Will output:
https://howchoo.com/g/print-the-current-page-url-in-modx
If you break down the expression, you'll see this approach is a combination of:
[[~12345]] => returns the page URL for resource 12345
and:
[[*id]] => normally returns the current page's resource ID
By nesting these, we can return the page URL for the resource ID of the current page.
Whether you're using a Raspberry Pi desktop or headless, you'll likely need to open a Linux shell at some point.