OnLoadWebDocument
Last updated May 4th, 2020 | 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
$301 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: None
Event Parameters¶
None. The resource can be referenced via $modx->resource.
Return Values¶
Any values returned from this event will be written as errors to the logs.
Usage¶
* Some of this may not be accurate because I'm testing this via trial and error.
You can use this event to set resource parameters at runtime or perform logging. E.g.
// 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;
Note that modifying resource parameters during the first page load (before the resource is cached) will cause those parameters to be written to the cache file. E.g. changing the template at this point will cause the resource _content
to store the contents of the newly referenced template.
After a page has been cached (i.e. not the first page load), you can append or prepend content (or overwrite it entirely) by modifying the _content property.
$modx->resource->_content = 'Content override';