We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    Hello Everyone,

    At the heart of the content manager you will find bits of plugin plugin interface codes. Plugins are special resources that are invoked or triggered whenever a system event occurs. In other words a plugin can only be executed whenever the event that it’s listening to is invoked.

    There are five system services currently available:

    1. Template System Service
    2. Manager Access and Security Service
    3. Web Access and Security Service
    4. Cache Service
    5. Parser (Kernel) Services (low level)

    Each service can raise an event to alert plugins of a system action that is above to be executed or one that has already been executed. For example, The OnManagerLogin event is immediately after a user logs into the manager. Using this event a plugin can be created to check and log the time and date that a user logins into the system.

    Another example is the use of the OnFormPrerender and OnFormRender system event. By listening to these events a plugin can extend the UI of any manager form available within the system. For example, pluginA can be made to listen to the OnUserFormRender and inserts a checkbox at the end of the page whenever the user form is loaded. The value of this check box can be later retrieved when the plugin is called via the OnUserSaveForm event:

    $evtname = $modx->Event->name;
    swicth ($evtname) {
    	case "OnUserFormRender": // show checkbox
    		echo "<input type='checkbox' name='pluginA_checkbox' />";
    		break;
    	case "OnUserSaveForm":	// get checkbox value
    		$chkbox = $_POST['pluginA_checkbox'];
    		// do something here
    		break;
    }
    


    There is no limit to what you can do with plugins and system events.
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 34162
      • 1 Posts
      Is there a complete list of all the events someplace? The OnUserFormRender/OnUserSaveForm events don't seem to be in the Dev Guide (although several others are) are there any other special ones?

      Also, I'm curious how the plugins are triggered. It looks as if every plugin has to be parsed on every event to see if it has anything to do.

      Is this the case?
        • 22303 MODX Staff
        • 10,725 Posts
        Great stuff Raymond. I will be considering how to support this on all core object attributes and user-defined object attributes in my object abstraction sub-project; I see development continuing as is in parallel until I can get my core system completed and start working it into the backend of the MODx core. These events would become Triggers on the attributes, which could then execute custom defined Rules, which when evaluated, could determine if a particular plug-in (or set of plug-ins) should be applied.

        Just trying to keep all these ideas tied together loosely until I have more information on the object abstraction work, and so others can consider/provide feedback on my vision in relation to other development.
          • 32963
          • 1,732 Posts
          Is there a complete list of all the events someplace? The OnUserFormRender/OnUserSaveForm events don't seem to be in the Dev Guide (although several others are) are there any other special ones?

          There are more events to come. No complete list as yet.


          Also, I'm curious how the plugins are triggered. It looks as if every plugin has to be parsed on every event to see if it has anything to do.

          Is this the case?

          No. Only plugins that are listening to the event being invoked are parsed. All the other plugins remains dormant until their event is being invoked. In other words if PluginA is listening to EventA and pluginB is listening to EventB. PluginA will only be parsed when EventA is triggered. If PluginA was later made to listen to EventB then PluginA will be parsed whenever EventA or EventB is triggered.

          Does that make sense?
            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
            • 34162
            • 1 Posts
            Yep, sounds good.

            Have an emergency project that came up this afternoon for a race this weekend and now have a meeting that starts in 45 minutes that will last til 10 PM (eastern), but definitely excited about getting to read through the code and to get my grubby little fingers on it. smiley

            Thanks for the explanation!
              • 32963
              • 1,732 Posts
              . These events would become Triggers on the attributes, which could then execute custom defined Rules, which when evaluated, could determine if a particular plug-in (or set of plug-ins) should be applied.


              Sounds great OpenGeek.

              With the new system events everything is extensible wink You can even create plugins to manage other plugins. Such plugins can be used to also extend the user permission system from both backend as well as front end. All we now have to do is to add the appropiate triggers inside the system.

              And just to add to the above you'll also be able to trigger events from within other plugins or snippets smiley Or better yet register your own custom events laugh

              It's just another way to create and do more with less...
                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.
                • 32963
                • 1,732 Posts
                Yep, sounds good.

                Have an emergency project that came up this afternoon for a race this weekend and now have a meeting that starts in 45 minutes that will last til 10 PM (eastern), but definitely excited about getting to read through the code and to get my grubby little fingers on it. smiley

                Thanks for the explanation!

                You're welcome smiley

                I would sure love for everyone to have a look at the system and identity other system events that can be created or embedded withing the system.

                PS. The plugin infterace in CVS is not the latest. It's still being worked on.
                  xWisdom
                  www.xwisdomhtml.com
                  The fear of the Lord is the beginning of wisdom:
                  MODx Co-Founder - Create and do more with less.
                  • 32963
                  • 1,732 Posts
                  Hello Everyone

                  Here's some more information on system events:

                  System events
                  A system events can be viewed as a trigger or hook, which allows a plugin to extend the use and functionality of the content manager. With these events you can do just about anything you can think of. For example, you could use the OnBeforeDocFormSave event to implement your own document version control system or use the OnBeforeManagerLogout to save the current state of the content manager before the user logs out of the system.

                  Below you will find a list of built-in system events that are recognized by the content manager. Please note that event names are Case-Sensitive.

                  Template System Events:
                  OnDocPublished
                  OnDocUnPublished
                  OnWebPagePrerender


                  Web Access Events:
                  OnWebLogin
                  OnBeforeWebLogout
                  OnWebLogout
                  OnWebSaveUser
                  OnWebDeleteUser
                  OnWebChangePassword
                  OnWebCreateGroup


                  Manager Access Events:
                  OnManagerLogin
                  OnBeforeManagerLogout
                  OnManagerLogout
                  OnManagerSaveUser
                  OnManagerDeleteUser
                  OnManagerChangePassword
                  OnManagerCreateGroup

                  Cache Events:
                  OnBeforeCacheUpdate
                  OnCacheUpdate
                  OnLoadWebPageCache
                  OnBeforeSaveWebPageCache


                  Parser Service Events:
                  OnChunkFormPrerender
                  OnChunkFormRender
                  OnBeforeChunkFormSave
                  OnChunkFormSave
                  OnBeforeChunkFormDelete
                  OnChunkFormDelete

                  OnDocFormPrerender
                  OnDocFormRender
                  OnBeforeDocFormSave
                  OnDocFormSave
                  OnBeforeDocFormDelete
                  OnDocFormDelete

                  OnPluginFormPrerender
                  OnPluginFormRender
                  OnBeforePluginFormSave
                  OnPluginFormSave
                  OnBeforePluginFormDelete
                  OnPluginFormDelete

                  OnSnipFormPrerender
                  OnSnipFormRender
                  OnBeforeSnipFormSave
                  OnSnipFormSave
                  OnBeforeSnipFormDelete
                  OnSnipFormDelete

                  OnTempFormPrerender
                  OnTempFormRender
                  OnBeforeTempFormSave
                  OnTempFormSave
                  OnBeforeTempFormDelete
                  OnTempFormDelete

                  OnTVFormPrerender
                  OnTVFormRender
                  OnBeforeTVFormSave
                  OnTVFormSave
                  OnBeforeTVFormDelete
                  OnTVFormDelete

                  OnUserFormPrerender
                  OnUserFormRender
                  OnBeforeUserFormSave
                  OnUserFormSave
                  OnBeforeUserFormDelete
                  OnUserFormDelete

                  OnWUsrFormPrerender
                  OnWUsrFormRender
                  OnBeforeWUsrFormSave
                  OnWUsrFormSave
                  OnBeforeWUsrFormDelete
                  OnWUsrFormDelete

                  OnSiteRefresh
                  OnFileManagerUpload
                  OnCreateDocGroup

                  What do you think?
                    xWisdom
                    www.xwisdomhtml.com
                    The fear of the Lord is the beginning of wisdom:
                    MODx Co-Founder - Create and do more with less.
                    • 25663 MODX Staff
                    • 12,272 Posts
                    I think whoah! laugh

                    How cool, and can't wait to see what you smart folks can come up with!
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 25663 MODX Staff
                      • 12,272 Posts
                      The only question I've got about the system events is how do we control which ones get executed in what order? Could there be a potential for conflict?
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me