How to Print the Current Page URL in MODX

0

You can echo the current MODX resource's full page URL without the use of a snippet call.

Posted in these interests:

webdev
PRIMARY
86 subscribers
modx
0 subscribers

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.