

include_once('../../modxapi.php'); // http://modxcms.com/MODxAPI-Library-865.html
require_once('../../assets/libs/document.class.inc.php'); // http://modxcms.com/Docmanager-881.html
$modx = new MODxAPI();
$doc = new Document(51); // the doc id we want to access
$tv = $doc->Get("tvdocumentTags"); // get contents of TV "foo": note the prefix "tv" here!
$doc->Set("tvextraHead", "<!-- " . strrev($tv) . " -->"); // do something with TV 1 and save value in TV 2
$doc->Save();
)