We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    I am looking for a system event that is called when a document is moved.

    My plugin, automaticTpl is using OnDocFormPrerender to set the template of a new document.

    I would also like to change the template of the document when it is moved. I know it’s not a "nice" thing to do but I was wondering if it is possible.

    Thank You

      • 22797
      • 134 Posts
      This is something I would love to have control over too. I don’t think that event exists.

      Here’s a potentially complicating factor that is closely related: as far as I know, if you’re using the right-click menu, this bypasses the system events under some(?) circumstances (see http://modxcms.com/forums/index.php?topic=22759.0). That makes it problematic because you can’t count on the same results for actions initiated by the right-click menu vs. the icons over the top of the document. If you can find a way around that, or if you can disprove it, I’d love to hear about it.
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        When a document is moved, the cache is updated, so you could use the OnBeforeCacheUpdate or OnCacheUpdate event. You could then check and make sure the document has the template it should have. If there’s no document ID ($_REQUEST[’id’]) available (this wasn’t a document editing/moving cache event), just return to normal processing.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org