We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21700
    • 42 Posts
    Hi all,

    I’ve been busy creating a snippet that’s getting a page from a remote server (using cURL), parses it so links/forms will redirect to pages at my MODx site, and returns the page. Now this is working quite sweet, however, I have a problem importing one of the pages from the remote server. The thing is, the snippet breaks parsing and my website will only display a blank page.

    I was wondering if there is a way to check each step/debug this snippet, to find out what is causing the break of parsing.

    The things I’ve done so far:
    - Executing snippet with a different page as target: works fine.
    - Executing snippet with the breaking page as target, but the snippet stand-alone (without MODx): works fine.
    - Checking if the files are made by the page, that does work, it does react on the GET i send it.
    - returning another var instead of the parsed page (usually consisting of some divs, tables, lists and sometimes a script element).
    - Disabling Javascript to check wheter it’s the page that’s incorrectly parsed or some JS that redirects me to a blank page.
    - Checking wheter the script creates errors handled by the event log. It doesn’t.

    Things that don’t work:
    - Using ECHO or PRINTF to debug the snippet. The user always receives only 1 blank, completely empty HTML page.

    Anyway, I was wondering if there is a way to debug what is happening. It might be some HTML/JS in the page that breaks PHP, however I haven’t found anything strange. Since I don’t even get detailed error information, no fault lines or whatever, it puzzles and baffles me.

    And another question/remark: sometimes loading pages can take up to a few seconds. Is there a timeout mechanism in MODx?

    I have full (root) control over the server, PHP.ini etc are all customizable.

    Thank you all,

    daan

    PS: the pages I load are from one of our suppliers to display user information. This is all done with their consent, no law-breaking activities wink
      • 4041
      • 788 Posts
      Have you looked into the top menu Reports/ System Events log and see if it has anything there?

      I also have this piece of code you can add to your snippet to help figure out where the issue is, modify it accordingly to suit: (I did not write down the link to the original post where I got this code, so credit goes to the original author)

      <?php
      
      // Example
      if(!isset($needed_variable)) {
        $error_message = "[".$modx->getSnippetName()."] The following error occured while processing document ".$modx->documentIdentifier.": \n";
        $error_message.= "Your error message goes here.";
        $modx->Event->alert($error_message);
        $modx->logEvent(0, 3, $error_message, $modx->getSnippetName());
        return "<!-- ".$modx->getSnippetName()." failed -->";
      }
      ?>
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 21700
        • 42 Posts
        System events stays empty. And thank you for your lines of code, but I guess the snippet runs OK, since processing other pages does not generate any errors. It’s just the MODx parsing that fails whenever one certain page is loaded. I’d like to get some more insight in this process.