Handlers
The MODX events the package subscribes to, and what the framework does on each. Your own class with the same name runs after the framework one — see Events.
Request lifecycle
| Event | What the framework does |
|---|---|
OnMODXInit | Nothing yet. Registered with priority: 1000 so the component boots before other plugins that may depend on it. |
OnHandleRequest | Aliases modUser and modUserProfile to their MODX\Revolution\ counterparts, starts the session, mints the CSRF token if the session has none, switches the locale when the URI carries a language prefix, and hands the request to routing. Skips asset extensions (.css, .js, images, fonts) and, with pageblocks_routing = off, everything outside mgr/. |
OnWebPageInit | Front-end setup for the requested page: sends the security headers, registers the style layer through regClientCSS (unless pageblocks_load_styles is off), adds the reCAPTCHA script when a public key is filled in, and — unless pageblocks_load_scripts is off — the web scripts plus their configuration. |
OnCacheUpdate | Clears the route cache, the Fenom view cache, the component cache and the menu cache, and drops $_SESSION['pageblocks']. Runs whenever MODX clears its cache. |
The one case where the style layer needs a tag in the template
Because OnWebPageInit registers the block styles itself, an ordinary MODX page needs nothing from you — no {pb_styles()}, no manual <link>. But a page rendered by the component's own router never reaches that event: OnHandleRequest sends the response and returns first. In that template, and only there, put {pb_styles()} in the <head>.
Clearing the MODX cache clears ours
OnCacheUpdate means the manager's "Clear cache" button already covers PageBlocks — routes, compiled templates and cached lists. You rarely need to clear anything by hand.
Resource form
| Event | What the framework does |
|---|---|
OnDocFormPrerender | On an existing resource, loads the component's manager scripts. Skipped in new mode. |
OnDocFormRender | Renders the resource's section fields into the form. Skipped in new mode. |
OnBeforeDocFormSave | Collects the section field values from the submitted form and writes them into the resource. |
OnResourceDuplicate | Copies the resource's PageBlocks content to the copy: blocks, their nested tables and galleries, and rows attached to the resource's section fields. Custom field values ride along inside properties, which MODX copies itself. |
User form
| Event | What the framework does |
|---|---|
OnUserFormPrerender | Loads manager scripts for an existing user. Skipped in new mode. |
OnUserFormRender | Renders the user's section fields into the form. |
OnUserSave | Writes custom user fields into modx_user_attributes.extended. Runs after the core processor on purpose — otherwise the processor would overwrite extended. |
OnUserDuplicate | The user counterpart of OnResourceDuplicate. Accepts several spellings of the processor's parameters, because they differ between MODX builds. |
OnUserRemove | No framework handler. Registered so a site can hook it from core/App/Events/OnUserRemove.php. |
Manager
| Event | What the framework does |
|---|---|
OnManagerPageBeforeRender | Loads the base scripts, the data scripts and the rich text editor on every manager page. |
OnSiteSettingsRender | Adds modx.combo.js to the system settings page. |
Where the code is
Framework handlers live in core/components/pageblocks/src/Events/, one file per event. They are short and readable — when this page is not enough, the class itself usually is.