We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40045
    • 534 Posts
    Hm, ok, that would be a logical explanation, but on the other side I spent a decent amount of time to figure out how I could bypass that "problem" (pass some variable to an event that didn't seem to support $modx->resource and such complicated, unnecessary stuff) when I just accidentally found out, that $modx->resource is available anyway, even when the rtfm said "none", so maybe I would have to remove my rtfm-edit/"correction" in this case, but then it should definitely be mentioned somewhere, that with front-end events these variables are available. I mean, "normal" developers are just looking at the events and want to know what kind of variables they can use^^...how do you think about that logical vs. practical "fight" @Bob?
      • 3749
      • 24,544 Posts
      I think there ought to be somewhere that covers where $modx->user and $modx->resource are available (and not available), but I'm not sure where it should go and I'm not really qualified to write it.

        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
      • Use this plugin to get System Event's variables and its value. Don't forget to check System Event you want to know. Then see the report on Reports > Error Log.


        <?php
        $arg_list = func_get_args();
        $output = array();
        foreach($arg_list as $args) {
            if (is_array($args)) {
                foreach($args as $key => $val) {
                    $value = 'OBJECT';
                    try {
                        //don't print the object, especially $resource/$xpdo object coz too big
                        if (!is_object($val)) {
                            if (is_array($val)) {
                                $value = "(Array)". serialize($val);
                            } else {
                                $value = $val;
                            }
                        }
                    } catch (Exception $e) {
                        $value = "(error)" . $e->getMessage();
                    }
                    $output[] = "[$key]: $value";
                }
            }
        }
        $text = "\n--------\nEVENT: " .$modx->event->name;
        foreach($output as $val) {
            $text .= "\n$val";
        }
        $text .= "\n--------";
        $modx->log(modX::LOG_LEVEL_ERROR, $text);
          zaenal.lokamaya
          • 40045
          • 534 Posts
          @lokamaya

          Thank you! That piece of code will be so helpful in many cases! =)!!