Jump to main content Jump to doc navigation

modResource.getAliasPath

Builds the alias path that becomes the Resource uri. When uri_override is set and uri is not empty, the frozen value is returned unchanged. Otherwise the alias is cleaned and prefixed with the ancestors when the context has use_alias_path. The path ends with the content type extension, or with container_suffix for a folder.

An empty $alias falls back to the cleaned pagetitle when the context has automatic_alias, and to the Resource ID when it does not. $fields lets you compute the path for values that are not stored on the object yet.

Syntax

string getAliasPath ([string $alias = '' [, array $fields = array()]])
  • $alias (string) alias to build the path from, by default ''
  • $fields (array) field values to use instead of the Resource's own, by default array()

Example

$resource = $modx->getObject('modResource', array('id' => 5));
$uri = $resource->getAliasPath('about-us');

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

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

$194 per month—let's make that $500!

Learn more