We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8439
    • 89 Posts
    I have tried searching but can’t find anything remotely resembling this.

    I would like to create thumbnails of images within a document when that document is created. Updating the thumbs when the doc is edited and deleting them when the doc is purged.

    The application in my case is Ditto, if a story has an image then the summary listing shows a thumb. Is it possible to cause code to be executed before and/or after a doc is created, edited or deleted?

    If so then a pointer to a TFM I could R would be appreciated, if not, what’s the best way to go about this?

    Ed
      • 15987
      • 786 Posts
      All of the following events are available for documents. These can be accessed by creating a plugin.

      OnBeforeDocFormDelete
      OnBeforeDocFormSave
      OnCreateDocGroup
      OnDocFormDelete
      OnDocFormPrerender
      OnDocFormRender
      OnDocFormSave
        • 8439
        • 89 Posts
        Quote from: kylej at Oct 16, 2006, 07:59 AM

        All of the following events are available for documents. These can be accessed by creating a plugin.
        Sigh, just found events and plugins and was about to edit my post.

        My processing only applies to documents created from a specific template. The documentation says that $modx->documentObject[’template’] contains the template ID, do I assume this is actually the template name?

        Ed
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I believe it’s the template ID, not its name. You’ll have to do a query of your own to get the correlation between ID and name.
            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
            • 8439
            • 89 Posts
            Quote from: kylej at Oct 16, 2006, 07:59 AM

            All of the following events are available for documents. These can be accessed by creating a plugin.

            OnBeforeDocFormDelete
            OnBeforeDocFormSave
            OnCreateDocGroup
            OnDocFormDelete
            OnDocFormPrerender
            OnDocFormRender
            OnDocFormSave

            OK, I create a doc from a template, when saving this doc I can use the OnDocFormSave event to create a thumbnail.

            I then edit the document and edit the contents of the TV containing the image file, perhaps erasing it, perhaps changing the image filename.

            When I save the document I can create a new thumbnail using the OnDocFormSave event. However the old thumbnail is now detached and represents unreclaimable resources.

            Do I use the OnBeforeDocFormSave event to access the previous value?

            Also the delete events, are they when items are marked for delete or when the item is actually removed?

            Ed
              • 32963
              • 1,732 Posts
              Hi ed,

              The FormDelete events occurs before and after a document is flagged as deleted and not when the document is actually delete. I think it would be a great idea to add an event when the document is being removed from the system.
                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.