Jump to main content Jump to doc navigation

Event: 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

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

$194 per month—let's make that $500!

Learn more