We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2249
    • 60 Posts
    Hi All,

    Can anyone tell me if its possible and how to set a default resource group for a newly created resource to belong to in settings? I cant find any options to do this in Site/Context Settings.

    Regards
    Ash Finlayson
      • 2249
      • 60 Posts
      Anyone have an answer for this?
        • 37099
        • 338 Posts
        Maybe you could write a Plugin that allocates the resource to the resource group OnDocFormPrerender or similar.

        Mike
          • 3749
          • 24,544 Posts
          I think you can use Form Customization to set a default value for the resource group field.

          As thingstodo suggests, there's probably a way to do it with a plugin tied to OnDocFormPrerender,
          or you could use a plugin tied to OnBeforeDocFormSave. I think this would work:

          <?php
          /* Default group plugin */
          
          if ($mode === modSystemEvent::MODE_NEW) {
              $modx->resource->joinGroup('resource_group_name_or_id');
          }
            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
            • 2249
            • 60 Posts
            Cheers guys, I hadn't realised a plugin could do the job. Sounds perfect

            Ash
              • 24629
              • 370 Posts
              Quote from: BobRay at Dec 23, 2011, 05:52 PM
              I think you can use Form Customization to set a default value for the resource group field.

              As thingstodo suggests, there's probably a way to do it with a plugin tied to OnDocFormPrerender,
              or you could use a plugin tied to OnBeforeDocFormSave. I think this would work:

              <!--?php
              /* Default group plugin */
              
              if ($mode === modSystemEvent::MODE_NEW) {
                  $modx--->resource->joinGroup('resource_group_name_or_id');
              }

              This does not seem to work anymore in MODX 2.6-PL
              Ik created a new plugin, on OnBeforeDocFormSave event. But the manager hangs after saving in a eternal 'Please wait ... saving' modal.
              Does the code nee to be different?

              TNX
              RDG
                • 3749
                • 24,544 Posts
                Duh. I forget to mention this (which I wrote): DefaultResourceGroup.
                  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