Skip to content

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

EventWhat the framework does
OnMODXInitNothing yet. Registered with priority: 1000 so the component boots before other plugins that may depend on it.
OnHandleRequestAliases modUser and modUserProfile to their MODX\Revolution\ counterparts, starts the session, and lets routing take over the request.
OnWebPageInitFront-end setup for the requested page.
OnCacheUpdateClears the route cache, the Fenom view cache, the component cache and the menu cache, and drops $_SESSION['pageblocks']. Runs whenever MODX clears its cache.

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

EventWhat the framework does
OnDocFormPrerenderOn an existing resource, loads the component's manager scripts. Skipped in new mode.
OnDocFormRenderRenders the resource's section fields into the form. Skipped in new mode.
OnBeforeDocFormSaveCollects the section field values from the submitted form and writes them into the resource.
OnResourceDuplicateCopies 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

EventWhat the framework does
OnUserFormPrerenderLoads manager scripts for an existing user. Skipped in new mode.
OnUserFormRenderRenders the user's section fields into the form.
OnUserSaveWrites custom user fields into modx_user_attributes.extended. Runs after the core processor on purpose — otherwise the processor would overwrite extended.
OnUserDuplicateThe user counterpart of OnResourceDuplicate. Accepts several spellings of the processor's parameters, because they differ between MODX builds.
OnUserRemoveNo framework handler. Registered so a site can hook it from core/App/Events/OnUserRemove.php.

Manager

EventWhat the framework does
OnManagerPageBeforeRenderLoads the base scripts, the data scripts and the rich text editor on every manager page.
OnSiteSettingsRenderAdds modx.combo.js to the system settings page.

Not subscribed

OnLoadWebDocument and OnPageNotFound are present in the package definition but commented out. If you need them, add them to the plugin's event list in the manager and put a class in core/App/Events/.

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.

© PageBlocks 2019-present