Last active
December 27, 2015 17:09
-
-
Save AgelxNash/7359671 to your computer and use it in GitHub Desktop.
Скрипт для сохранения значений ТВ параметров в properties документа
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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