We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34466
    • 19 Posts
    I created docs from an array using a snippet and it worked fine. I tried tpo do it from a php file from outside of modx and I get error call to a meber function get() on. a non-object in /create.classes.php on line 193. Is somthing missing from the script? Thanks. modx revo 2.2.0-pl2
     
    if (!defined('MODX_CORE_PATH')) {
         $outsideModx = true;  // optional -- for your own use.
        /* put the path to your core in the next line to run outside of MODx */
        define(MODX_CORE_PATH, '/httpdocs/core/');
        include_once MODX_CORE_PATH . '/model/modx/modx.class.php';
    global $modx;
        $modx= new modX();
        $modx->initialize('mgr');
        $modx->getService('error','error.modError');
    }
    
    $title = $row['name'];
    $link = $row['link'];
    $image = $row['image'];
    $description = $row['description'];
    $upc = $row['upc'];
    $price = $row['price'];
    $manufacturer = $row['manufacturer'];
    
    $fields = array(
    'pagetitle' => $title,
    'link_attributes' => $link,
    'summary' => $image,
    'content' => $description,
    'introtext' => $upc,
    'description' => $price,
    'longtitle' => $manufacturer);
    
    /* create and save new resource */
    $response = $modx->runProcessor('resource/create', $fields);
    
     

    [ed. note: Bloggerpimp last edited this post 14 years, 8 months ago.]
      • 3749
      • 24,544 Posts
      You may need the full path in the the define for the MODX_CORE_PATH. Remember that it's a file path, not a URL.

      e.g., on localhost, c://xampp/htdocs/core/

      The error message is telling you that MODX is not being initialized, almost for sure because MODX_CORE_PATH is incorrect.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        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