fwiw, here’s a fully functional, basic example (0.9.6. on LAMP setup), running as a standalone PHP script:
<?php
include_once('../../modxapi.php'); // include the API class
$modx = new MODxAPI();
$modx->connect();
$modx->getSettings();
require_once('../libs/docmanager/document.class.inc.php'); // include the docmanager class (d'oh)
$doc = new Document();
$doc->Set('pagetitle', "Dinner was delicious!");
$doc->Set('parent', 56);
$doc->Set('alias', 'post'.time());
$doc->Set('content', 'Oh, hello! This is a new post generated via the docManager class.');
$doc->Set('template', 'basic');
$doc->Set('cacheable', 0);
$doc->Set('hidemenu', 0);
$doc->Set('tvpageKeywords', 'API, MODx, development, tests'); // TV 1 - TV name = pageKeywords
$doc->Set('tvpageDescription', 'Just a basic test using the (3rd party) docManager class from an external PHP script.'); // TV 2 - TV name = pageDescription
$doc->Save();
$newID = $doc->fields['id'];
// alternatively, use $modx->makeUrl($newID) if SEO-friendly URLs are activated
echo "New document was created: <a href='http://www.mysite.com/index.php?id=$newID' target='_blank'>id #$newID</a>";
?>
imo, you really only need to remember to include the modx api class*, and add "tv" prefix.
So, if your TV is called "keywords", use "tvkeywords" instead. That’s really all there is to it.
I’ve used this now on at least 3 different sites, from 0.9.5 to 0.9.6.1, WAMP + XAMPP without problems.
It can really be a great timesaver when you have to copy old content from a DB to a new site with MODx. I’m not saying it’s the only tool around. There’s the CSV importer, FDM, and probably other stuff I’ve missed. But this has been working nicely for me.
* if it’s running inside a snippet, you don’t need that of course