Hi Bob,
Just to let you know that your code to add resources to a resource group "Pubbed" worked great.
I added the leaveGroup method so that when unpublished it removed the resource from the resource group.
So my final code was
<?php
$groupId = 5; /* Important: Set to ID of 'Pubbed' Resource Group (shown in Security -> Resource Groups). */
if (!$resource->get('published')) {
/* Not published */
/* Make sure it's not already in the group */
if ($modx->getObject('modResourceGroupResource', array(
'document_group' => $groupId,
'document' => $resource->get('id')))) {
/* Already in group so remove */
$resource->leaveGroup($groupId);
return;
}
return;
}
/* Published */
/* Make sure it's not already in the group */
if ($modx->getObject('modResourceGroupResource', array(
'document_group' => $groupId,
'document' => $resource->get('id')))) {
/* Already in group */
return;
}
$resource->joinGroup($groupId);
And I also set it to trigger for OnDocPublished and OnDocUnPublished (in addition to OnDocFormSave) so it responded to the right click publishing toggle.
Many thanks again for putting me on the right path
regards
Ian.