Создание ресурсов, через Modx API
Поле createdon проставляется текущей датой, а publishedon вообще не подставляется. Как сделать чтобы они подставлялись из массива?
1
<?php
$array = array(
array('pagetitle' => '16 октября - открытие театрального ..','content' => 'Нельзя не отметить ....','date' => '1444946460')
);
foreach($array as $v){
$response = $modx->runProcessor('resource/create', array(
'template' => 3,
'isfolder' => 0,
'published' => 1,
'createdby' => 2,
'parent' => 2,
'pagetitle' => $v['pagetitle'],
'createdon' => $v['date'],
'publishedon' => $v['date'],
'introtext' => $v['introtext'],
'content' => $v['content'],
'class_key' => 'Article',
));
if ($response->isError()) {
return $modx->error->failure($response->getMessage());
}
$modx->cacheManager->clearCache();
}РЕШЕНО!foreach($array as $v){
$response = $modx->runProcessor('resource/create', array(
'template' => 3,
'isfolder' => 0,
'published' => 1,
'createdby' => 2,
'parent' => 2,
'pagetitle' => $v['pagetitle'],
'createdon' => date("Y-m-d H:i:s" , $v['date']),
'publishedon' => date("Y-m-d H:i:s" , $v['date']),
'introtext' => $v['introtext'],
'content' => $v['content'],
'class_key' => 'Article',
));
if ($response->isError()) {
return $modx->error->failure($response->getMessage());
}
$modx->cacheManager->clearCache();
}
Комментарии: 1