modResource.canPreviewResource
Last updated not available | 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 moremodResource.canPreviewResource¶
Validates a preview target before the manager builds a preview URL. A $targetId whose string form starts with 0 — 0 itself and strings like 05 — is rejected first; then the target is loaded and must not be deleted. Every failure path writes a resource_err_preview_* lexicon message to the error log; $sourceId only selects which message a failure logs. Self-previews — $sourceId equal to $targetId or not passed at all — get their own entries.
The method is declared with a bool return type and always returns a boolean. Only getPreviewUrl() calls it in core.
Syntax¶
boolean canPreviewResource (int|string $targetId [, int|string|null $sourceId = null])
-
$targetId(int|string) ID of the Resource to be previewed -
$sourceId(int|string|null) ID of the Resource the preview was requested from, by defaultnull
Example¶
$resource = $modx->getObject('modResource', array('id' => 5));
if ($resource->canPreviewResource(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
Budget
$194 per month—let's make that $500!
Learn more










