Quote from: Everett at Jan 21, 2011, 11:44 PM
How about adding a page to a certain Resource Group programmatically?
elastic’s method should work fine (and would be a little faster), but there’s an easier way now:
$resource->joinGroup($group);
$group can be a resource group object, the ID of the resource group, or the name of the resource group (using the ID would be fastest).
I’m shooting from the hip here, but I think if you just want the user group IDs in an array, this would do it:
<?php
$id = $modx->resource->get('id');
$rgrs = $modx->getCollection('modResourceGroupResource', array('document'=>$id));
$groups = array();
foreach($rgrs as $rgr) {
$groups[] = $rgr->get('document_group');
}
/* see if we got them */
$output = implode(',', $groups);
return $output;