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

    could anybody explain me how exactly the document publishing system works ? I want to call a funtion before something will be published but couldn´t find anything about how the mechanism works.

    Would be very cool if you could help me.

    Best regards
    Neobe
      • 27708 MODX Staff
      • 2,502 Posts
      When you say before it will be published do you mean in advance of it being published or as it gets published. THere is a System Event (that can be used with a plugin) called onDocPublished that is triggered as a document gets published.

      http://wiki.modxcms.com/index.php/API:Template_Service_Events#OnDocPublished
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 3749
        • 24,544 Posts
        If you need to catch things before the publication status has changed in the DB, your plugin could listen for the OnDocBeforeFormSave event and check the publication status to see if it is going to change.

        OnDocBeforeFormSave fires for new and to-be-updated resources and executes after the object has been created or found and after fields and TVs have been set, but before any publication date checks, or user permission checks have been done and before the resource is saved to the database
          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
          • 21165
          • 4 Posts
          Hi thanks...

          I mean before it gets published, could you also explain me how exactly the publishing mechanism works ?

          Best regards
            • 27708 MODX Staff
            • 2,502 Posts
            Neobe,

            There is documentation on the Order of Execution and System Events in the User Wiki this details how the "publishing mechanism" works.

            If you have specific questions relating to that feel free to ask again.
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
              • 21165
              • 4 Posts
              Hi

              ok, cool thank you very much.

              Yes I just got one Question is there some kind of a OnBeforeDocPublish method ? Because I need to call my function just before the document is published.

              Or could iI fit this with the OnDocBeforeSave method anyhow ?

              Thanks a lot best regards
              NeoBe
                • 3749
                • 24,544 Posts
                OnDocPublished fires after the DB is updated. Unfortunately, there’s no OnBeforeDocPublished event (though you could file a Jira request via the link at the top of this page and ask that one be added).

                At this point, OnDocBeforeFormSave might be the way to go. It executes before the db is altered.
                  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