modX.makeUrl
Last updated Oct 14th, 2026 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodX::makeUrl¶
Generates a URL representing a specified resource.
Syntax¶
string makeUrl (integer $id, [string $context = ''], [string|array $args = ''], [mixed $scheme = -1], [array $options = array()])
$id(integer) The id of a resource. required$context(string) Specifies a context to limit URL generation to.$args(string|array) A query string to append to the generated URL.$scheme(mixed) The scheme indicates in what format the URL is generated — an integer constant or a string:-1: (default value) URL is relative tosite_url0: see http1: see httpsfull: URL is absolute, prepended withsite_urlfrom configabsorabsolute: URL is absolute, prepended withbase_urlfrom confighttp: URL is absolute, forced to http schemehttps: URL is absolute, forced to https scheme
$options(array) An array of options for generating the Resource URL.
Examples¶
Make a URL for Resource with ID 4.
$url = $modx->makeUrl(4);
Make a URL for Resource with ID 12 with an explicit HTTPS scheme.
$url = $modx->makeUrl(12, '', '', 'https', array('xhtml_urls' => false));
Make a URL for Resource with ID 25, but add a ?hello=world to the URL.
$url = $modx->makeUrl(25, '', array('hello' => 'world'));
$url = $modx->makeUrl(25, '', 'hello=world');
The same arguments can be passed to the [[~link]] tags:
[[~123? &scheme=`full`]]
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










