We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • This code isn't going anywhere because, from what I understand, the functionality will be handled by the core in Revo 2.3. In the meantime, I need new resources to inherit the resource groups of their parents. I think this should be the default behavior, sort of like file systems have inheritable permissions.

    Here's the code I'm using to handle things while I wait for 2.3. Does anyone have suggestions? Is there a better way to do this?

    It's a plugin that fires when resources are saved:

    /* Inherit resource groups only if resource is new */
    if ($mode == modSystemEvent::MODE_NEW) {
       
       /* get the id of the parent */
       $parentId = $_POST['parent'];
    
       /* get all the resource group data of the parent as a collection */
       $groupCollection = $modx->getCollection('modResourceGroupResource', array('document'=>$parentId));
    
       /* join the resource to resource groups in the collection */
       foreach($groupCollection as $group) {
          $success = $resource->joinGroup($group->get('document_group'));
       }
    }


    (I also hacked together some code to batch set resource groups to children of a selected parent. The current drag-and-drop-one-resource-at-a-time interface doesn't work at all for large sites. I'm hoping that interface will also be improved soon.)
      Time is what keeps everything from happening all at once.
      • 38017
      • 18 Posts
      Thank you! Works like a charm. I was having problems with the "Inherit Group Resource" from the package resource since it overrides your settings every time you save.