Skip to content

Instantly share code, notes, and snippets.

@maxpoletaev
Last active December 17, 2015 19:39
Show Gist options
  • Save maxpoletaev/5661702 to your computer and use it in GitHub Desktop.
Save maxpoletaev/5661702 to your computer and use it in GitHub Desktop.
Snippet for MODx Revolution. Displays the desired field from the resource.
<?php
if (!isset($id) || !isset($field)) return;
$resource = $modx->getObject('modResource', $id);
if (!$resource) return;
$data = $resource->toArray();
if (isset($data[$field])) {
return $data[$field];
} else {
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment