We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    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;
    }
    
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 22303 MODX Staff
      • 10,725 Posts
      Great stuff! You are the man! Keep the excellent examples coming. wink
        • 32963
        • 1,732 Posts
        Thanks a lot. I’ll certainly try to keep them coming.
          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.
          • 33337
          • 3,975 Posts
          Great work xWisdom,

          Thanks for sharing with us,

          Regards,

          zi
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 10702
            • 107 Posts
            Thanks a lot for this Plugin. How do I have to modify the Plugin for using it in Revo?

            Gerdi