We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34466
    • 19 Posts
    Hi, I need to use runProcessor to create new docs/resources from an array. I have the command that I need to run, but no clue how to set that up. Do I need to use xpdo? Is there a simple way to run it with the classes already included in modx? I read the 2.2 manual on using runprocessor, but it doesnt tell you how to set it up, just an example of a command (which I already have). Any help would be greatly appreciated. Thanks.
    $fields = array(
    'pagetitle' => $title,
    'link_attributes' => $link,
    'summary' => $image,
    'content' => $description,
    'introtext' => $upc,
    'description' => $price,
    'longtitle' => $manufacturer);
    
    /* create and save new resource */
    $response = $this->modx->runProcessor('resource/create', $fields);
    [ed. note: Bloggerpimp last edited this post 12 years, 2 months ago.]
      • 34466
      • 19 Posts
      BobRay Reply #2, 22 hours, 6 min ago


      You don't need to involve xPDO in any way, and if you're running it as a snippet, It should work just like it is. Just put a tag for the snippet on a page and preview the page (but don't do it more than once).

      If you want to run it outside of MODX, you just need to include this code at the top with the correct path to your MOD core:

      <?php
      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, 'c:/xampp/htdocs/test/core/');
          include_once MODX_CORE_PATH . '/model/modx/modx.class.php';
          $modx= new modX();
          $modx->initialize('mgr');
      }
      

      [ed. note: rethrash last edited this post 11 years, 7 months ago.]