We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43220
    • 4 Posts
    I need to show some data in modx 404 event.

    I have some files in a directory. When i got a specific url in 404 event i wanted to show a file from a specific directory which is not a modx resource.

    I was not able to show any custom output.
    how can i do that?


    in plugin i have set plugin event to
    OnPageNotFound
    and i have tried like this:

     global $modx;
        if ($modx->event->name == 'OnPageNotFound') {
           $out = file_get_contents('my_file');
           $modx->event->output( $out);
        }


    i also tried like this:

    global $modx;
        if ($modx->event->name == 'OnPageNotFound') {
           $out = file_get_contents('my_file');
           $strContent = &$modx->resource->_output;
           $strContent = $out;
        }


    I am using modx revo 2.*
      Best Regards,
      Awlad
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I think you'll need to use static resources, and in the plugin forward to the appropriate static resource.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 40045
        • 534 Posts
        If your external file is html or someting parsable (for the browser), you can just make a static resource out of it as Susan suggested and then use $modx->sendRedirect() to redirect the user to that file.