We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13391
    • 18 Posts
    I've searched around and haven't seen a way to redirect MODx parse errors to a simple page not found page.

    Does anyone know a way to do this?

    Thanks in advance for any assistance.
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      What exactly do you mean? You mean you want to pre-emptively detect parse errors and redirect the user if errors were detected?

      I haven't heard of that type of thing...

      What version of MODX are you using?
        • 13391
        • 18 Posts
        I'm using Evolution 1.0.2

        Yes in order to create a more streamlined experience for users, and increase security by not displaying any information a hacker could use. I'd like to redirect any parse error to a page not found for my production environment.

        Could a plugin be used to accomplish such a thing? Something like this:

        if ($modx->event->name == 'OnPageNotFound') {
             $errorPage = $modx->getOption('pnf.page');
             if (empty($errorPage)) {
                 $modx->sendErrorPage();
             } else {
                 $mailto = $modx->getOption('pnf.mailto');
                 if (!empty($mailto)) {
                    // send a message to a local account
                    $resourceId = $modx->resource->get('id');
                    $subject = 'Page not found';
                    $body = 'Someone tried to access document id '.$resourceId;
                    $modx->getService('mail', 'mail.modPHPMailer');
                    $modx->mail->set(modMail::MAIL_BODY, $body);
                    $modx->mail->set(modMail::MAIL_FROM, '$modx->getOption('pnf.mailfrom'));
                    $modx->mail->set(modMail::MAIL_FROM_NAME, 'MODx');
                    $modx->mail->set(modMail::MAIL_SENDER, 'MODx');
                    $modx->mail->set(modMail::MAIL_SUBJECT, $subject);
                    $modx->mail->address('to',$mailto);
                    $modx->mail->setHTML(true);
                    $modx->mail->send();
                 }
                 $url = $this->makeUrl($scriptProperties['page']);
                 $modx->sendRedirect($url, 1);
                 exit;
            }
        }


        Except instead of triggering when the page isn't found (OnPageNotFound) trigger whenever a parse error is detected.
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          I don't think there's an "onParserError" event... and you should probably upgrade to 1.0.5. You may have to do something hacky, but that is a problem in Evo.
            • 4041
            • 788 Posts
            You should definately upgrade to evolution 1.0.5. Although there isn't any way of redirecting on a parse error, the 1.0.5 version just shows a blank page to visitors on the frontend if an error occurs. If you are logged into the manager and view the errored page, a printout describing the error issue is shown.
              xforum
              http://frsbuilders.net (under construction) forum for evolution
              • 3749
              • 24,544 Posts
              What, exactly, do you mean by a parse error? Your code suggests that you just mean a page-not-found event. If so, you can designate any page as the error page and put a snippet on it that does whatever you want.

              You might also look at the LogPageNotFound package for Revolution. I think it could be adapted to work in Evolution.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                I believe the OP is referring to Evo's noisome habit of displaying juicy system info when the parser hits a snag.
                  • 13391
                  • 18 Posts
                  This is great information guys! I'll be upgrading to 1.0.5

                  Yes I've been referring to Evo's noisome habit of displaying juicy system information, and although a blank page isn't exactly what I've been looking for it is preferable to what 1.0.2 is doing.

                  I really wish there was an "onParseError" event as it would be very useful and not too difficult to implement.
                    • 9207 ☆ A M B ☆
                    • 2,475 Posts
                    It's already a feature request: http://bugs.modx.com/issues/1985
                      • 13391
                      • 18 Posts
                      I've upgraded my Evo install to 1.0.5 in my local environment. However I am still getting the noisome « MODx Parse Error » displayed to the user when the parser encounters a problem.

                      Any other suggestions on how I can get rid of these client displayed parse errors?