We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3515
    • 19 Posts
    Hi, everyone! Sorry for worry, but here is another question: I have a task to making a parser, which will parse catalog structure, and then insert it into the database as modx document. With parser itself is no trouble, but with inserting... I try to use MODx Revolution, and there is no understandable documentation about "how to use", so I searched info and copy-pasted it into my code:

    require_once('core/components/docbuilder/moddocumentbuilder.class.inc.php');
    $doc=new modDocumentBuilder();
    


    Note, that this code in the EXTERNAL php file (for launch it via CRON)

    Here is error message: Fatal error: Call to a member function load() on a non-object in core\components\docbuilder\moddocumentbuilder.class.inc.php on line 158 (File on attachment). Where I was wrong?

    Thanks in advance!

    P.S.: Sorry for my English... rolleyes
      • 22303 MODX Staff
      • 10,725 Posts
      What is the purpose of this class? You need to create Resources through the new Revolution API’s.
        • 3515
        • 19 Posts
        The purpose is to create Resource from the parsed data via the external PHP file. The problem is seems to I don’t know the correct way to connect Revolution docAPI to an external file... Here is a code, thats works fine on evolution:

        include_once('manager/includes/config.inc.php');
        include_once(MODX_MANAGER_PATH.'/includes/document.parser.class.inc.php');
        include_once('classes/docAPI.php');
        $doc=new Document($id);
        $doc->set('hidemenu','1');
        $doc->set('cacheable','0');					
        $doc->set('template','masterklass_production');
        $doc->set('tvproductcode',$catalog[$f]['код_товара']);
        $doc->set('pagetitle',$catalog[$f]['наименование']);				
        $doc->set('tvprice',$catalog[$f]['цена']);
        $doc->set('tvcargo',$ost);
        $doc->set('tvbutton',$but_capt);
        $doc->set('tvartikul',$catalog[$f]['артикул']);
        $doc->set('tvedizm',$catalog[$f]['единица']);
        $doc->set('parent',$parent);
        $doc->set('content','{{add2cart}}');
        $thumb='assets/images/production/thumbs/'.$catalog[$f]['код_товара'].'jpg';
        if(file_exists($thumb)){$doc->set('tvimage',$thumb);}
        $doc->save();
        


        But the same schema doesn’t work on revo. It’s seems like I wasn’t connect some important class or library, but I don’t know, which one...
          • 3749
          • 24,544 Posts
          Revolution has a whole different API based on xPDO.

          See Creating New Objects here: http://bobsguides.com/revolution-objects.html.

          If you need to run the code outside of MODx, that method is different also:

          define('MODX_CORE_PATH', 'full/path/to/your/modx/core/');
          define('MODX_CONFIG_KEY', 'config');
          require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
          $modx= new modX();
          $modx->initialize('mgr');
          
            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
            • 3515
            • 19 Posts
            Thank you very much! It is exactly what I was searching for!)))