Search code examples
phpmodxmodx-revolution

How to create a new document (Resource) from PHP


I would like to create an automated system that creates new Document (Resources Pages) using PHP instead of the UI. However I cant find any tutorial on how to do that from PHP.

Does anyone know how could I do that or if I can do that?

I am using Modx Revolution


Solution

  • This should do it:

    $resource = $modx->newObject('modResource');
    $resource->fromArray(array(
        'pagetitle' => 'My Resource Title',
        // add other resource properties here
    ));
    $resource->save();
    

    There are some forum posts and articles out there that will help you with this, if you Google hard enough...