This question has been answered by multiple community members. See the first response.
$rgrs = $resource->getMany('ResourceGroupResources');
foreach ($rgrs as $rgr) {
$groupId = $rgr->get('document_group');
$group = $modx->getObject('modResourceGroup', $groupId);
$groupName = $group->get('name');
}
<?php
$returnString = "";
$rgrs = $modx->resource->getMany('ResourceGroupResources');
foreach ($rgrs as $rgr) {
$groupId = $rgr->get('document_group');
$group = $modx->getObject('modResourceGroup', $groupId);
if($group)
{
$groupName = $group->get('name');
if($groupName != "")
{
if($returnString == "")
$returnString = $groupName;
else
$returnString = $returnString . '...............' . $groupName;
}
}
}
return $returnString;