We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Let me see if I get it. You want to put all resources that are children of another resource into the same resource group? You don't want resources at the root level of the tree in that group, but all other resources should be?

    If that's it, this plugin would do it (connected to OnDocFormSave):

    if ($resource->get('parent') != 0) {
        $resource->joinGroup('MyResourceGroup);
    }


    If will only work when you save a resource, and I don't think it will work with Quick Create.
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 20215
      • 144 Posts
      ok so the only way is with a plug-in
      I thought I could do with MIGXdb (something like "Set the Template for our children")

      thanks Bob
        ----------------------------------
        canale irc Italiano #modx server: tophost.azzurra.org
        • 3749
        • 24,544 Posts
        I'm not that familiar with MIGX, so it might be possible. I tend to use plugins for everything like that.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 4172
          • 5,888 Posts
          the childresourses-update-processor uses the modx-resources-create/update-processors. So I think a plugin should work.
          you can also create a custom-update-processor in a new directory and specify the processors-path in the MIGXdb - configuration.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 20215
            • 144 Posts
            hi Bruno
            yes OnDocFormSave plugin work

            <?php
            
            $templateObj = $resource->getOne('Template');
            if(!$templateObj){
            	$modx->log(modX::LOG_LEVEL_ERROR, "template empty");
            	return false; //exit plugin
            }
            $templateObjName = $templateObj->get('templatename');
            $templateValid = array("articolo_cliente");
            //check Template
            if(in_array($templateObjName, $templateValid)) {
            	if ($resource->get('parent') != 0) {
            		$resource->joinGroup('Clients Only');
            	}
            }
            
              ----------------------------------
              canale irc Italiano #modx server: tophost.azzurra.org
              • 4172
              • 5,888 Posts
              hi Bruno
              yes OnDocFormSave plugin work

              great! Thanks for reporting
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 3749
                • 24,544 Posts
                If you look in the parentheses next to the template in the Element tree, you'll see its ID. This would be significantly faster and more reliable (it doesn't get the entire template object for every save -- which you don't need -- and it will still work if you change the name of the template ):


                <?php
                // if (! $mode == modSystemEvent::MODE_NEW) return '';
                $templateId = $resource->get('template');
                if ($templateId == 12) {   /* replace 12 with template ID */
                    if ($resource->get('parent')) {
                        $resource->joinGroup('Clients Only');
                    }
                }


                Uncomment the first line once all existing resources are in the group that should be. That will make it even faster because you only need it for new resources.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 20215
                  • 144 Posts
                  right! thanks for the tips Bob
                    ----------------------------------
                    canale irc Italiano #modx server: tophost.azzurra.org