We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34017
    • 898 Posts
    How would I do the following as a plugin? Im feeling dumb today.


    <?php
    
    function error_handler( $errno, $errstr, $errfile, $errline )
    {
       $html = '<script type="text/javascript">';
       $html .= "console.error('PHP (line: %s) %s | %s');";
       $html .= '</script>';
       
       printf( $html, $errline, $errstr, addslashes($errfile) );
       
       return true;
    }
    
    error_reporting(E_ALL);
    set_error_handler("error_handler");
    
    ?>
    

      Chuck the Trukk
      ProWebscape.com :: Nashville-WebDesign.com
      - - - - - - - -
      What are TV's? Here's some info below.
      http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
      http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
      • 22303 MODX Staff
      • 10,725 Posts
      First, put your function in an include_once or wrap it in if (!function_exists(’your_error_handler_function’)); though this is not absolutely necessary, it’s good practice none-the-less.

      Then, simply register that code in a plugin for OnWebPageInit. That should do it, though I’ve never tried this in 0.9.x so I cannot guarantee it will work. In Revolution, you can provide your own error_handler class and specify it via System Settings, as well as override it in Context Settings; this will then be used as soon as a context is initialized, no plugin necessary.