We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4971
    • 964 Posts
    How can I troubleshoot plugins?
    When I use print_r or var_dump to show variables,
    nothing is shown... I guess because it is the manager...
    I have checked the log, but there is nothing there...
      Website: www.mercologia.com
      MODX Revo Tutorials:  www.modxperience.com

      MODX Professional Partner
      • 3749
      • 24,544 Posts
      Quote from: charliez at Oct 14, 2009, 06:04 PM

      How can I troubleshoot plugins?
      When I use print_r or var_dump to show variables,
      nothing is shown... I guess because it is the manager...
      I have checked the log, but there is nothing there...

      There are ways to do it, but I can never remember them so I usually just write the stuff to a text file. wink


      $fp = fopen('c:/test.txt', 'w+');
      fwrite($fp, $variable);
      fclose($fp);
        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
        • 4971
        • 964 Posts
        Nope, it does not work... I am developing in the server
        and it gives me an error that the parser does not give
        permission to fopen a file...

        there has to be another way!
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 4971
          • 964 Posts
          Any help on the topic?

          I have tested and troubleshooted using a snippet as far as I can go,
          but know I want to do the Plugin part... any ideas?

          TIA
            Website: www.mercologia.com
            MODX Revo Tutorials:  www.modxperience.com

            MODX Professional Partner
            • 3749
            • 24,544 Posts
            Quote from: charliez at Oct 14, 2009, 07:58 PM

            Nope, it does not work... I am developing in the server
            and it gives me an error that the parser does not give
            permission to fopen a file...

            there has to be another way!

            Write the file in a directory you have write access to?

            I’m definitely no expert in this department. Sometimes you can put the debugging message in the event’s output (assuming the output is displayed somewhere).

            Here’s what to do in Revo: http://modxcms.com/forums/index.php/topic,39829.msg240823.html#msg240823.

            In Evo, try:

            webAlert(’message’);
            $modx->webAlert(’message’);
            error_log(’message’);
            die(’message’);

            BTW, sometimes print_r() doesn’t work becuase the variable you’re sending it is an object rather than an array.
              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
              • 4971
              • 964 Posts
              Thanks Bob, I will try that...
              your link gives me this:

              An Error Has Occurred!
              The topic or board you are looking for appears to be either missing or off limits to you.

              And I am logged in... huh
                Website: www.mercologia.com
                MODX Revo Tutorials:  www.modxperience.com

                MODX Professional Partner
                • 3749
                • 24,544 Posts
                Quote from: charliez at Oct 19, 2009, 01:42 PM

                Thanks Bob, I will try that...
                your link gives me this:

                An Error Has Occurred!
                The topic or board you are looking for appears to be either missing or off limits to you.

                And I am logged in... huh
                Sorry, it’s in a restricted area of the forums. Here’s the gist of it:

                Use:

                $modx->log('message');


                After changing the "log target" via $modx->setLogTarget($target), to "ECHO". By default, the target is a file target definition which points at the core/cache/logs/error.log. The setLogTarget() function returns the current target so you can set it back once you are done redirecting to another target temporarily.

                I haven’t tried this in Evo, but it may work.

                [Update] I just checked and Evo doesn’t appear to have setLogTarget().
                  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
                  • 4971
                  • 964 Posts
                  Thanks Bob, I think that between webAlert and logEvent
                  I have a way to see what is going on in the plugin...
                  thanks again Bob...

                  Carlos
                    Website: www.mercologia.com
                    MODX Revo Tutorials:  www.modxperience.com

                    MODX Professional Partner
                    • 3749
                    • 24,544 Posts
                    Quote from: charliez at Oct 19, 2009, 04:58 PM

                    Thanks Bob, I think that between webAlert and logEvent
                    I have a way to see what is going on in the plugin...
                    thanks again Bob...

                    Carlos

                    Don’t thank me until it works. wink
                      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