Jump to main content Jump to doc navigation

modResource.getPreviewUrl

Returns the URL behind the manager's Preview button. For a plain document the method calls modX::makeUrl() for this Resource. Symlinks must hold an integer target. Weblinks may hold an ID, a [[~id]] tag, a link tag with options, or an external URL. The ID variants are validated with canPreviewResource().

An empty string comes back for a deleted Resource, an empty or invalid link, or a target failing the check; null is never returned. When the context has sessions disabled, the URL gets a preview=true query parameter. The call has a side effect: the cache_alias_map option is switched off for the rest of the request.

Syntax

string getPreviewUrl ()

Example

$resource = $modx->getObject('modResource', array('id' => 5));
$url = $resource->getPreviewUrl();

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