$context = $modx->context->key;
$name = 'modResource';
$criteria = array(
'published' => 1,
'pagetitle' => $pagetitle,
'context' => $context
);
$resource = $modx->getObject($name,$criteria);
$docid = $resource->get('id');This question has been answered by BobRay. See the first response.
Try this:
'context_key' => $context