OnLoadWebDocument
Last updated Oct 14th, 2026 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moreEvent: OnLoadWebDocument¶
Fires directly before the Response is sent and after a Resource is loaded.
- Service: 5 - Template Service Events
- Group: System
Event Parameters¶
None. The resource can be referenced via $modx->resource.
Return Values¶
Values returned from this event are written to the log as errors.
Usage¶
Set Resource properties at runtime or log data:
// Set all pages to be uncached (for debugging)
$modx->resource->set('cacheable', 0);
// Or switch the template
$modx->resource->set('template', 6);
// Alternate syntax
$modx->resource->template = 6;
Changing properties on the first page load writes them to the cache file. Changing the template there makes the cached resource _content hold the output of the new template.
After the page has been cached (any later load), append, prepend or replace output by modifying the _content property:
$modx->resource->_content = 'Content override';
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










