We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21496
    • 225 Posts
    In snippets, we see often code like this:

    <?php
    
    // we set at the beginning:
    global $modx;
    
    // then we might declare a variable like this:
    $verifyUrl = $modx->config['base_url'];
    
    ?>
    
    


    As we have some trouble with base_url in this Thread , it would be handy for debugging to print out the content of the $modx array, to see what variables are available.

    I was believing I can do this with print_r($modx), but that throws an error.

    Can someone provide a code snippet that can display the content of $modx? That would be very helpful for debugging snippets. Thanks!
      René
      • 33372
      • 1,611 Posts
      $modx is an object, not an array, so that’s the source of the error you’re seeing. You can get the best syntax for outputting all of its values from the MODx wiki here. But you may want to consider only outputting the info that you need to view instead, as suggested by Jason here.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 21496
        • 225 Posts
        Thanks ZAP, that helped a lot! What I needed in my case was inserting

        return '<pre>' . print_r($modx->config, 1) . '</pre>';


        to print the config array. (This must be an array, because Jason said so ... wink .. hehe )

        By the way, I like your comment to the Buddha quote in your signature! laugh
          René