MODX Cloud

The Most Productive MODX Learning Playground Ever

Claim Free Lab Account

modX.makeUrl

Skip to end of metadata
Go to start of metadata


modX::makeUrl

Generates a URL representing a specified resource.

The scheme indicates in what format the URL is generated.

  • -1 : (default value) URL is relative to site_url
  • 0 : see http
  • 1 : see https
  • full : URL is absolute, prepended with site_url from config
  • abs : URL is absolute, prepended with base_url from config
  • http : URL is absolute, forced to http scheme
  • https : URL is absolute, forced to https scheme

Syntax

API Doc: http://api.modx.com/revolution/2.2/db_core_model_modx_modx.class.html#%5CmodX::makeUrl()

string makeUrl (integer $id, [string $context = ''], [string $args = ''], [mixed $scheme = -1])

Examples

Make a URL for the Resource with ID 4.

$url = $modx->makeUrl(4);

Make a URL for the Resource with ID 12, but make sure it's in HTTPS.

$url = $modx->makeUrl(12,'','','https');

Make a URL to Resource with ID 56, but add a ?fun=123 to the URL.

$url = $modx->makeUrl(56,'',array('fun' => '123'));
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.