We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42562
    • 1,145 Posts
    Haven't I too been waiting for this feature for so long?

    All my poor contexts/websites get the boot whenever their subling is cache-drained, poor fellows! suffering the punishment due to another.
      TinymceWrapper: Complete back/frontend content solution.
      Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
      5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
      • 3749
      • 24,544 Posts
      This is totally off the top of my head, but I think something like this might do it (I think you'd have to have CacheMaster running as well, to prevent clearing the whole cache).

      This would be connected to OnDocFormSave:

      /** recursive remove dir function */
      function rrmdir($dir) {
          if (is_dir($dir)) {
              $objects = scandir($dir);
              foreach ($objects as $object) {
                  if ($object != "." && $object != "..") {
                      if (filetype($dir . "/" . $object) == "dir") {
                          $this->rrmdir($dir . "/" . $object);
                      } else {
                          unlink($dir . "/" . $object);
                      }
                  }
              }
              reset($objects);
              rmdir($dir);
          }
      }
      
      $contextKey = $modx->resource->get('context_key');
      
      rrmdir(MODX_CORE_PATH . 'cache/resource/' . $context_key);
      



        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
      • This is somewhat related, but I wish the final delete trashcan was also context sensitive. The workaround to make it so is not a good one. Not being a programmer I get the feeling that contexts as a thing are not part of the standard bunch of functions with MODX itself here and there as well as Extras (i.e. ClientConfig, various calendar extensions for example) so it's easier to write things that have no idea about contexts than to write elements that have contexts in mind.
          • 37914
          • 89 Posts
          Thanx BobRay,
          I will test your plugin.

          @ rx2: I stopped using clientconfig and found using the context settings on the contexts it selves much more useful and more versatile.
          • Yes, we use Context Settings as well, though we do find that a bit more dangerous for clients who may fiddle with something they shouldn't.