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

    I’m sure it’s something stupid I’m doing, but I’ve set up a basic plugin which fires onDocPublished.
    However, when I try to reference the $modx object, it does not return anything.

    Is the object not available for this event, or do I need to reference it in a different way?

    My test code basically reads:

    file_put_contents(’<path to my root>/test.txt’, $modx->documentObject[’pagetitle’]);

    The file is created, but is left empty.

    Thanks,

    Pete
      • 22303 MODX Staff
      • 10,725 Posts
      You need to specify more information (as requested in red below the input field when you post here in the forums) about what version of MODX you are using, at the very least.
        • 4041
        • 788 Posts
        If you are using Evolution, you will have to use a query to get any document info since only the document id is sent to the plugin event.
        // invoke OnDocPublished  event
        $modx->invokeEvent("OnDocPublished",array("docid"=>$id));
        


        Maybe something like this:
        <?php
        $pagetitle = $modx->db->getValue( $modx->db->select( 'pagetitle', $modx->getFullTableName('site_content'), 'id="'.$docid.'"' ) );
        
        file_put_contents('<path to my root>/test.txt', $pagetitle);
          xforum
          http://frsbuilders.net (under construction) forum for evolution
          • 23129
          • 1 Posts
          Hi guys.

          @Breezer - perfect! Thank you.

          @opengeek - apologies. I assumed that, since I was posting under the Evo branch, that would be enough. And, since I wasn’t posting about a bug, it was just a query, that extra info wasn’t necessary. I’ll make sure I post everything next time.

          Anyways - all solved.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: PeteWJ at Jul 25, 2011, 03:33 PM

            @opengeek - apologies. I assumed that, since I was posting under the Evo branch, that would be enough. And, since I wasn’t posting about a bug, it was just a query, that extra info wasn’t necessary. I’ll make sure I post everything next time.
            That was my bad actually, I didn’t notice the board was sub-board of the Evolution board. embarrassed