This little plugin is used to demonstrate how you can easily intercept calls to the MODx error page redirector. The plugin will send an alert message to a manager user account and if necessary redirect the web user to another page.
To install, create a new plugin and enable enable (or check) the "OnPageNotFound" event from the system events page. Next, copy and paste the "Plugin configuration" string below into the configuration textbox. Finally, copy and paste the "Plugin code" into textbox provided on the plugin page.
Trigger Event:
-------------------
OnPageNotFound
Plugin configuration:
--------------------
&pg=Error Page;int;13 &mid=Mail To;string;admin
Plugin Code:
--------------------
$e = &$modx->Event;
switch($e->name) {
case "OnPageNotFound":
if(!$pg) $modx->sendErrorPage();
else {
$subject = "Page not found";
$msg = "Someone tried to access document id ".$modx->documentIdentifier;
$modx->sendAlert("404 Error",$mid,0,$subject,$msg,0);
$url=$this->makeUrl($pg);
$this->sendRedirect($url, 1);
exit;
}
break;
default: // stop here
break;
}