Сделал по примеру добавление документа по данным формы
<?php
function createNewResource( &$fields ){
global $modx;
$values = array();
$values['pagetitle'] = $modx->db->escape($fields['title']);
$values['longtitle'] = '';
$values['description'] = '';
$values['alias'] = '';
$values['published'] = 0; //0 - if you want the document to be created unpublished
$values['parent'] = 2; //id of the container for the the new document
$values['introtext'] = '';
$values['content'] = $modx->db->escape($fields['content']);
$values['template'] = 3; //the template of your new document
$values['searchable'] = 1;
$values['cacheable'] = 1;
$values['createdby'] = 1; //this is not the web user ID. Change it to an existing manager id
$values['createdon '] = time();
$values['editedby'] = 1; //this is not the web user ID. Change it to an existing manager id
$values['editedon '] = time();
//you can find more document properties by browsing the modx_site_content table
//insert the new document. In case you need the id of the new document use the $newId variable
$newId = $modx->db->insert( $values, $modx->getFullTableName('site_content') );
$customValues = array();
$customValues['tmplvarid'] = 1;//ID TV
$customValues['contentid'] = $newId;
$customValues['value'] = $modx->db->escape($fields['email']);
$modx->db->insert( $customValues, $modx->getFullTableName('site_tmplvar_contentvalues') );
//clear the cache. in case you use Ditto to display the new document
clearCache();
return true;
}
function clearCache() {
include_once "manager/processors/cache_sync.class.processor.php";
$sync = new synccache();
$sync->setCachepath("assets/cache/");
$sync->setReport(false);
$sync->emptyCache();
}
?>
При добавлении TV например
$customValues['tmplvarid'] = 2;//ID TV
$customValues['contentid'] = $newId;
$customValues['value'] = $modx->db->escape($fields['phone']);
В документе сохраняется только последний TV-параметр.
Вопрос в следующем. Как сделать так что бы сохранялись несколько TV-параметров?
Очень надеюсь на вашу помощь!