Skip to content

Instantly share code, notes, and snippets.

@AgelxNash
Last active December 27, 2015 17:09
Show Gist options
  • Save AgelxNash/7359671 to your computer and use it in GitHub Desktop.
Save AgelxNash/7359671 to your computer and use it in GitHub Desktop.
Скрипт для сохранения значений ТВ параметров в properties документа
<?php
$data = array(
array(
'id' => '8', //ID TV параметра с числом просмотров
'name' => 'hitts',
'key' => 'hitspage',
'int' => true
),
array(
'id' => '15', //ID TV параметра с числом комментариев
'name' => 'comment',
'key' => 'count',
'int' => true
)
);
foreach($data as $tv){
$tvn = $modx->getCollection("modTemplateVarResource",array('tmplvarid' => $tv['id'] ));
foreach($tvn as $item){
$count = $item->get('value');
if($tv['int']){
$count = intval($count);
}
$DOC = $modx->getObject('modResource', $item->contentid);
$DOC->setProperty($tv['name'], $count, $tv['key']);
$DOC->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment