Jump to main content Jump to doc navigation

System Events

Other versions: 3.x — Other languages: EN RU — Found a problem? Please edit this page or report an issue.

What are System Events?

System Events are the events in MODX that Plugins are registered to. They are 'fired' throughout the MODX code, allowing Plugins to interact with MODX code and add custom functionality without hacking core code.

The Model of a System Event

The system events table is found under {table_prefix}_system_eventnames, and has the following fields:

  • id - The unique ID of the event.
  • name - The name of the event. This is how they are referenced in code, via the modX.invokeEvent method.
  • service - What type of system event this event is.
  • groupname - Used for user interfaces, primarily for filtering, grouping and sorting of events. Not used explicitly in the modx model.

Service Types

The 'service' field in the System event is a number; the numbers reference different types of System Events. They are:

  • 1 - Parser Service Events
  • 2 - Manager Access Events
  • 3 - Web Access Service Events
  • 4 - Cache Service Events
  • 5 - Template Service Events
  • 6 - User Defined Events

3 is not fired in the 'mgr' context; 2 is not fired in any context but 'mgr'.

Available Events

This is not an exhaustive list as events are still being documented. Thank you for your patience. The TV, Template and Snippet events are still to be documented. For a complete list, please either view a Plugin in the manager and see the System Events tab, or view here. Note also that all WUsr (web-user) events have been removed.

  1. OnBeforeCacheUpdate
  2. OnBeforeChunkFormDelete
  3. OnBeforeChunkFormSave
  4. OnBeforeDocFormDelete
  5. OnBeforeDocFormSave
  6. OnBeforeEmptyTrash
  7. OnBeforeManagerLogin
  8. OnBeforeManagerLogout
  9. OnBeforeManagerPageInit
  10. OnBeforePluginFormDelete
  11. OnBeforePluginFormSave
  12. OnBeforeSaveWebPageCache
  13. OnBeforeSnipFormDelete
  14. OnBeforeSnipFormSave
  15. OnBeforeTempFormDelete
  16. OnBeforeTempFormSave
  17. OnBeforeTVFormDelete
  18. OnBeforeTVFormSave
  19. OnBeforeUserActivate
  20. OnBeforeUserFormDelete
  21. OnBeforeUserFormSave
  22. OnBeforeWebLogin
  23. OnBeforeWebLogout
  24. OnCacheUpdate
  25. OnCategoryBeforeRemove
  26. OnCategoryBeforeSave
  27. OnCategoryRemove
  28. OnCategorySave
  29. OnChunkBeforeRemove
  30. OnChunkBeforeSave
  31. OnChunkFormDelete
  32. OnChunkFormPrerender
  33. OnChunkFormRender
  34. OnChunkFormSave
  35. OnChunkRemove
  36. OnChunkSave
  37. OnContextBeforeRemove
  38. OnContextBeforeSave
  39. OnContextFormPrerender
  40. OnContextFormRender
  41. OnContextRemove
  42. OnContextSave
  43. OnDocFormDelete
  44. OnDocFormPrerender
  45. OnDocFormRender
  46. OnDocFormSave
  47. OnDocPublished
  48. OnDocUnPublished
  49. OnEmptyTrash
  50. OnFileManagerBeforeUpload
  51. OnFileManagerUpload
  52. OnFileManagerDirCreate
  53. OnFileManagerDirRemove
  54. OnFileManagerDirRename
  55. OnFileManagerFileCreate
  56. OnFileManagerFileRemove
  57. OnFileManagerFileRename
  58. OnFileManagerFileUpdate
  59. OnFileManagerMoveObject
  60. OnHandleRequest
  61. OnInitCulture
  62. OnLoadWebDocument
  63. OnLoadWebPageCache
  64. OnManagerAuthentication
  65. OnManagerLogin
  66. OnManagerLoginFormPrerender
  67. OnManagerLoginFormRender
  68. OnManagerLogout
  69. OnManagerPageAfterRender
  70. OnManagerPageBeforeRender
  71. OnManagerPageInit
  72. OnMODXInit
  73. OnPageNotFound
  74. OnPageUnauthorized
  75. OnParseDocument
  76. OnPluginBeforeRemove
  77. OnPluginBeforeSave
  78. OnPluginEventRemove
  79. OnPluginFormDelete
  80. OnPluginFormPrerender
  81. OnPluginFormRender
  82. OnPluginFormSave
  83. OnPluginRemove
  84. OnPluginSave
  85. OnPropertySetBeforeRemove
  86. OnPropertySetBeforeSave
  87. OnPropertySetRemove
  88. OnPropertySetSave
  89. OnResourceAutoPublish
  90. OnResourceGroupBeforeRemove
  91. OnResourceGroupBeforeSave
  92. OnResourceGroupRemove
  93. OnResourceGroupSave
  94. OnRichTextBrowserInit
  95. OnRichTextEditorInit
  96. OnRichTextEditorRegister
  97. OnSiteRefresh
  98. OnSiteSettingsRender
  99. OnTemplateVarBeforeRemove
  100. OnTemplateVarBeforeSave
  101. OnTemplateVarRemove
  102. OnTemplateVarSave
  103. OnUserActivate
  104. OnUserBeforeRemove
  105. OnUserBeforeSave
  106. OnUserChangePassword
  107. OnUserFormDelete
  108. OnUserFormSave
  109. OnUserNotFound
  110. OnUserRemove
  111. OnUserSave
  112. OnWebAuthentication
  113. OnWebLogin
  114. OnWebLogout
  115. OnWebPageComplete
  116. OnWebPageInit
  117. OnWebPagePrerender

Custom Events

You can create your own custom events, but there is currently no GUI available for this; instead you must use the API. Events have the following attributes:

  • name - the unique event name.
  • service - loose attempt to group events for particular areas. 1,2,4,5,6 are loaded inside the manager, whereas 1,3,4,5,6 are loaded outside the manager. (see getEventMap())
  • groupname - Used for visually grouping the events in the MODX manager (visible as a Plugin tab).

Creating an event using the MODX API would look something like this:

$Event = $modx->newObject('modEvent');
$Event->set('name', 'OnMyCustomEvent');
$Event->set('service',1);
$Event->set('groupname', 'Custom');

Then your code could trigger that event by name:

$modx->invokeEvent('OnMyCustomEvent', $options);

Finally, a plugin could be set to listen for that event. In this case, it can receive options passed to it.

//... TODO...

See Also

  1. System Events
  2. OnBeforeCacheUpdate
  3. OnBeforeChunkFormDelete
  4. OnBeforeChunkFormSave
  5. OnBeforeDocFormDelete
  6. OnBeforeDocFormSave
  7. OnBeforeManagerLogout
  8. OnBeforeSaveWebPageCache
  9. OnBeforeWebLogout
  10. OnCacheUpdate
  11. OnChunkFormDelete
  12. OnChunkFormPrerender
  13. OnChunkFormRender
  14. OnChunkFormSave
  15. OnDocFormDelete
  16. OnDocFormPrerender
  17. OnDocFormRender
  18. OnDocFormSave
  19. OnDocPublished
  20. OnDocUnPublished
  21. OnLoadWebPageCache
  22. OnManagerLogin
  23. OnManagerLogout
  24. OnSiteRefresh
  25. OnUserChangePassword
  26. OnWebLogin
  27. OnWebLogout
  28. OnWebPagePrerender
  29. OnManagerPageBeforeRender
  30. OnTemplateVarBeforeSave
  31. OnTemplateVarSave
  32. OnTemplateVarBeforeRemove
  33. OnTemplateVarRemove
  34. OnBeforeEmptyTrash
  35. OnBeforeManagerLogin
  36. OnBeforeManagerPageInit
  37. OnBeforePluginFormDelete
  38. OnBeforePluginFormSave
  39. OnBeforeSnipFormDelete
  40. OnBeforeSnipFormSave
  41. OnBeforeTempFormDelete
  42. OnBeforeTempFormSave
  43. OnBeforeTVFormDelete
  44. OnBeforeTVFormSave
  45. OnBeforeUserActivate
  46. OnBeforeUserFormDelete
  47. OnBeforeUserFormSave
  48. OnBeforeWebLogin
  49. OnCategoryBeforeRemove
  50. OnCategoryBeforeSave
  51. OnCategoryRemove
  52. OnCategorySave
  53. OnChunkBeforeRemove
  54. OnChunkBeforeSave
  55. OnChunkRemove
  56. OnChunkSave
  57. OnContextBeforeRemove
  58. OnContextBeforeSave
  59. OnContextFormPrerender
  60. OnContextFormRender
  61. OnContextRemove
  62. OnContextSave
  63. OnEmptyTrash
  64. OnFileManagerBeforeUpload
  65. OnFileManagerUpload
  66. OnFileManagerDirCreate
  67. OnFileManagerDirRemove
  68. OnFileManagerDirRename
  69. OnFileManagerFileCreate
  70. OnFileManagerFileRemove
  71. OnFileManagerFileRename
  72. OnFileManagerFileUpdate
  73. OnFileManagerMoveObject
  74. OnHandleRequest
  75. OnInitCulture
  76. OnLoadWebDocument
  77. OnManagerAuthentication
  78. OnManagerLoginFormPrerender
  79. OnManagerLoginFormRender
  80. OnManagerPageAfterRender
  81. OnManagerPageInit
  82. OnPageNotFound
  83. OnPageUnauthorized
  84. OnParseDocument
  85. OnPluginBeforeRemove
  86. OnPluginBeforeSave
  87. OnPluginEventRemove
  88. OnPluginFormDelete
  89. OnPluginFormPrerender
  90. OnPluginFormRender
  91. OnPluginFormSave
  92. OnPluginRemove
  93. OnPluginSave
  94. OnPropertySetBeforeRemove
  95. OnPropertySetBeforeSave
  96. OnPropertySetRemove
  97. OnPropertySetSave
  98. OnResourceAutoPublish
  99. OnResourceGroupBeforeRemove
  100. OnResourceGroupBeforeSave
  101. OnResourceGroupRemove
  102. OnResourceGroupSave
  103. OnRichTextBrowserInit
  104. OnRichTextEditorInit
  105. OnRichTextEditorRegister
  106. OnSiteSettingsRender
  107. OnUserActivate
  108. OnUserBeforeRemove
  109. OnUserBeforeSave
  110. OnUserFormDelete
  111. OnUserFormSave
  112. OnUserNotFound
  113. OnUserRemove
  114. OnUserSave
  115. OnWebAuthentication
  116. OnWebPageComplete
  117. OnWebPageInit